diff options
Diffstat (limited to 'include/net/irda')
34 files changed, 3852 insertions, 0 deletions
diff --git a/include/net/irda/af_irda.h b/include/net/irda/af_irda.h new file mode 100644 index 000000000000..7a209f61c482 --- /dev/null +++ b/include/net/irda/af_irda.h | |||
@@ -0,0 +1,87 @@ | |||
1 | /********************************************************************* | ||
2 | * | ||
3 | * Filename: af_irda.h | ||
4 | * Version: 1.0 | ||
5 | * Description: IrDA sockets declarations | ||
6 | * Status: Stable | ||
7 | * Author: Dag Brattli <dagb@cs.uit.no> | ||
8 | * Created at: Tue Dec 9 21:13:12 1997 | ||
9 | * Modified at: Fri Jan 28 13:16:32 2000 | ||
10 | * Modified by: Dag Brattli <dagb@cs.uit.no> | ||
11 | * | ||
12 | * Copyright (c) 1998-2000 Dag Brattli, All Rights Reserved. | ||
13 | * Copyright (c) 2000-2002 Jean Tourrilhes <jt@hpl.hp.com> | ||
14 | * | ||
15 | * This program is free software; you can redistribute it and/or | ||
16 | * modify it under the terms of the GNU General Public License as | ||
17 | * published by the Free Software Foundation; either version 2 of | ||
18 | * the License, or (at your option) any later version. | ||
19 | * | ||
20 | * Neither Dag Brattli nor University of Tromsų admit liability nor | ||
21 | * provide warranty for any of this software. This material is | ||
22 | * provided "AS-IS" and at no charge. | ||
23 | * | ||
24 | ********************************************************************/ | ||
25 | |||
26 | #ifndef AF_IRDA_H | ||
27 | #define AF_IRDA_H | ||
28 | |||
29 | #include <linux/irda.h> | ||
30 | #include <net/irda/irda.h> | ||
31 | #include <net/irda/iriap.h> /* struct iriap_cb */ | ||
32 | #include <net/irda/irias_object.h> /* struct ias_value */ | ||
33 | #include <net/irda/irlmp.h> /* struct lsap_cb */ | ||
34 | #include <net/irda/irttp.h> /* struct tsap_cb */ | ||
35 | #include <net/irda/discovery.h> /* struct discovery_t */ | ||
36 | #include <net/sock.h> | ||
37 | |||
38 | /* IrDA Socket */ | ||
39 | struct irda_sock { | ||
40 | /* struct sock has to be the first member of irda_sock */ | ||
41 | struct sock sk; | ||
42 | __u32 saddr; /* my local address */ | ||
43 | __u32 daddr; /* peer address */ | ||
44 | |||
45 | struct lsap_cb *lsap; /* LSAP used by Ultra */ | ||
46 | __u8 pid; /* Protocol IP (PID) used by Ultra */ | ||
47 | |||
48 | struct tsap_cb *tsap; /* TSAP used by this connection */ | ||
49 | __u8 dtsap_sel; /* remote TSAP address */ | ||
50 | __u8 stsap_sel; /* local TSAP address */ | ||
51 | |||
52 | __u32 max_sdu_size_rx; | ||
53 | __u32 max_sdu_size_tx; | ||
54 | __u32 max_data_size; | ||
55 | __u8 max_header_size; | ||
56 | struct qos_info qos_tx; | ||
57 | |||
58 | __u16_host_order mask; /* Hint bits mask */ | ||
59 | __u16_host_order hints; /* Hint bits */ | ||
60 | |||
61 | void *ckey; /* IrLMP client handle */ | ||
62 | void *skey; /* IrLMP service handle */ | ||
63 | |||
64 | struct ias_object *ias_obj; /* Our service name + lsap in IAS */ | ||
65 | struct iriap_cb *iriap; /* Used to query remote IAS */ | ||
66 | struct ias_value *ias_result; /* Result of remote IAS query */ | ||
67 | |||
68 | hashbin_t *cachelog; /* Result of discovery query */ | ||
69 | __u32 cachedaddr; /* Result of selective discovery query */ | ||
70 | |||
71 | int nslots; /* Number of slots to use for discovery */ | ||
72 | |||
73 | int errno; /* status of the IAS query */ | ||
74 | |||
75 | wait_queue_head_t query_wait; /* Wait for the answer to a query */ | ||
76 | struct timer_list watchdog; /* Timeout for discovery */ | ||
77 | |||
78 | LOCAL_FLOW tx_flow; | ||
79 | LOCAL_FLOW rx_flow; | ||
80 | }; | ||
81 | |||
82 | static inline struct irda_sock *irda_sk(struct sock *sk) | ||
83 | { | ||
84 | return (struct irda_sock *)sk; | ||
85 | } | ||
86 | |||
87 | #endif /* AF_IRDA_H */ | ||
diff --git a/include/net/irda/crc.h b/include/net/irda/crc.h new file mode 100644 index 000000000000..f202296df9bb --- /dev/null +++ b/include/net/irda/crc.h | |||
@@ -0,0 +1,29 @@ | |||
1 | /********************************************************************* | ||
2 | * | ||
3 | * Filename: crc.h | ||
4 | * Version: | ||
5 | * Description: CRC routines | ||
6 | * Status: Experimental. | ||
7 | * Author: Dag Brattli <dagb@cs.uit.no> | ||
8 | * Created at: Mon Aug 4 20:40:53 1997 | ||
9 | * Modified at: Sun May 2 20:25:23 1999 | ||
10 | * Modified by: Dag Brattli <dagb@cs.uit.no> | ||
11 | * | ||
12 | ********************************************************************/ | ||
13 | |||
14 | #ifndef IRDA_CRC_H | ||
15 | #define IRDA_CRC_H | ||
16 | |||
17 | #include <linux/types.h> | ||
18 | #include <linux/crc-ccitt.h> | ||
19 | |||
20 | #define INIT_FCS 0xffff /* Initial FCS value */ | ||
21 | #define GOOD_FCS 0xf0b8 /* Good final FCS value */ | ||
22 | |||
23 | /* Recompute the FCS with one more character appended. */ | ||
24 | #define irda_fcs(fcs, c) crc_ccitt_byte(fcs, c) | ||
25 | |||
26 | /* Recompute the FCS with len bytes appended. */ | ||
27 | #define irda_calc_crc16(fcs, buf, len) crc_ccitt(fcs, buf, len) | ||
28 | |||
29 | #endif | ||
diff --git a/include/net/irda/discovery.h b/include/net/irda/discovery.h new file mode 100644 index 000000000000..eb0f9de47294 --- /dev/null +++ b/include/net/irda/discovery.h | |||
@@ -0,0 +1,100 @@ | |||
1 | /********************************************************************* | ||
2 | * | ||
3 | * Filename: discovery.h | ||
4 | * Version: | ||
5 | * Description: | ||
6 | * Status: Experimental. | ||
7 | * Author: Dag Brattli <dagb@cs.uit.no> | ||
8 | * Created at: Tue Apr 6 16:53:53 1999 | ||
9 | * Modified at: Tue Oct 5 10:05:10 1999 | ||
10 | * Modified by: Dag Brattli <dagb@cs.uit.no> | ||
11 | * | ||
12 | * Copyright (c) 1999 Dag Brattli, All Rights Reserved. | ||
13 | * Copyright (c) 2000-2002 Jean Tourrilhes <jt@hpl.hp.com> | ||
14 | * | ||
15 | * This program is free software; you can redistribute it and/or | ||
16 | * modify it under the terms of the GNU General Public License as | ||
17 | * published by the Free Software Foundation; either version 2 of | ||
18 | * the License, or (at your option) any later version. | ||
19 | * | ||
20 | * This program is distributed in the hope that it will be useful, | ||
21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
23 | * GNU General Public License for more details. | ||
24 | * | ||
25 | * You should have received a copy of the GNU General Public License | ||
26 | * along with this program; if not, write to the Free Software | ||
27 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, | ||
28 | * MA 02111-1307 USA | ||
29 | * | ||
30 | ********************************************************************/ | ||
31 | |||
32 | #ifndef DISCOVERY_H | ||
33 | #define DISCOVERY_H | ||
34 | |||
35 | #include <asm/param.h> | ||
36 | |||
37 | #include <net/irda/irda.h> | ||
38 | #include <net/irda/irqueue.h> /* irda_queue_t */ | ||
39 | #include <net/irda/irlap_event.h> /* LAP_REASON */ | ||
40 | |||
41 | #define DISCOVERY_EXPIRE_TIMEOUT (2*sysctl_discovery_timeout*HZ) | ||
42 | #define DISCOVERY_DEFAULT_SLOTS 0 | ||
43 | |||
44 | /* | ||
45 | * This type is used by the protocols that transmit 16 bits words in | ||
46 | * little endian format. A little endian machine stores MSB of word in | ||
47 | * byte[1] and LSB in byte[0]. A big endian machine stores MSB in byte[0] | ||
48 | * and LSB in byte[1]. | ||
49 | * | ||
50 | * This structure is used in the code for things that are endian neutral | ||
51 | * but that fit in a word so that we can manipulate them efficiently. | ||
52 | * By endian neutral, I mean things that are really an array of bytes, | ||
53 | * and always used as such, for example the hint bits. Jean II | ||
54 | */ | ||
55 | typedef union { | ||
56 | __u16 word; | ||
57 | __u8 byte[2]; | ||
58 | } __u16_host_order; | ||
59 | |||
60 | /* Same purpose, different application */ | ||
61 | #define u16ho(array) (* ((__u16 *) array)) | ||
62 | |||
63 | /* Types of discovery */ | ||
64 | typedef enum { | ||
65 | DISCOVERY_LOG, /* What's in our discovery log */ | ||
66 | DISCOVERY_ACTIVE, /* Doing our own discovery on the medium */ | ||
67 | DISCOVERY_PASSIVE, /* Peer doing discovery on the medium */ | ||
68 | EXPIRY_TIMEOUT, /* Entry expired due to timeout */ | ||
69 | } DISCOVERY_MODE; | ||
70 | |||
71 | #define NICKNAME_MAX_LEN 21 | ||
72 | |||
73 | /* Basic discovery information about a peer */ | ||
74 | typedef struct irda_device_info discinfo_t; /* linux/irda.h */ | ||
75 | |||
76 | /* | ||
77 | * The DISCOVERY structure is used for both discovery requests and responses | ||
78 | */ | ||
79 | typedef struct discovery_t { | ||
80 | irda_queue_t q; /* Must be first! */ | ||
81 | |||
82 | discinfo_t data; /* Basic discovery information */ | ||
83 | int name_len; /* Lenght of nickname */ | ||
84 | |||
85 | LAP_REASON condition; /* More info about the discovery */ | ||
86 | int gen_addr_bit; /* Need to generate a new device | ||
87 | * address? */ | ||
88 | int nslots; /* Number of slots to use when | ||
89 | * discovering */ | ||
90 | unsigned long timestamp; /* Last time discovered */ | ||
91 | unsigned long firststamp; /* First time discovered */ | ||
92 | } discovery_t; | ||
93 | |||
94 | void irlmp_add_discovery(hashbin_t *cachelog, discovery_t *discovery); | ||
95 | void irlmp_add_discovery_log(hashbin_t *cachelog, hashbin_t *log); | ||
96 | void irlmp_expire_discoveries(hashbin_t *log, __u32 saddr, int force); | ||
97 | struct irda_device_info *irlmp_copy_discoveries(hashbin_t *log, int *pn, | ||
98 | __u16 mask, int old_entries); | ||
99 | |||
100 | #endif | ||
diff --git a/include/net/irda/ircomm_core.h b/include/net/irda/ircomm_core.h new file mode 100644 index 000000000000..69b610acd2df --- /dev/null +++ b/include/net/irda/ircomm_core.h | |||
@@ -0,0 +1,108 @@ | |||
1 | /********************************************************************* | ||
2 | * | ||
3 | * Filename: ircomm_core.h | ||
4 | * Version: | ||
5 | * Description: | ||
6 | * Status: Experimental. | ||
7 | * Author: Dag Brattli <dagb@cs.uit.no> | ||
8 | * Created at: Wed Jun 9 08:58:43 1999 | ||
9 | * Modified at: Mon Dec 13 11:52:29 1999 | ||
10 | * Modified by: Dag Brattli <dagb@cs.uit.no> | ||
11 | * | ||
12 | * Copyright (c) 1999 Dag Brattli, All Rights Reserved. | ||
13 | * | ||
14 | * This program is free software; you can redistribute it and/or | ||
15 | * modify it under the terms of the GNU General Public License as | ||
16 | * published by the Free Software Foundation; either version 2 of | ||
17 | * the License, or (at your option) any later version. | ||
18 | * | ||
19 | * This program is distributed in the hope that it will be useful, | ||
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
22 | * GNU General Public License for more details. | ||
23 | * | ||
24 | * You should have received a copy of the GNU General Public License | ||
25 | * along with this program; if not, write to the Free Software | ||
26 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, | ||
27 | * MA 02111-1307 USA | ||
28 | * | ||
29 | ********************************************************************/ | ||
30 | |||
31 | #ifndef IRCOMM_CORE_H | ||
32 | #define IRCOMM_CORE_H | ||
33 | |||
34 | #include <net/irda/irda.h> | ||
35 | #include <net/irda/irqueue.h> | ||
36 | #include <net/irda/ircomm_event.h> | ||
37 | |||
38 | #define IRCOMM_MAGIC 0x98347298 | ||
39 | #define IRCOMM_HEADER_SIZE 1 | ||
40 | |||
41 | struct ircomm_cb; /* Forward decl. */ | ||
42 | |||
43 | /* | ||
44 | * A small call-table, so we don't have to check the service-type whenever | ||
45 | * we want to do something | ||
46 | */ | ||
47 | typedef struct { | ||
48 | int (*data_request)(struct ircomm_cb *, struct sk_buff *, int clen); | ||
49 | int (*connect_request)(struct ircomm_cb *, struct sk_buff *, | ||
50 | struct ircomm_info *); | ||
51 | int (*connect_response)(struct ircomm_cb *, struct sk_buff *); | ||
52 | int (*disconnect_request)(struct ircomm_cb *, struct sk_buff *, | ||
53 | struct ircomm_info *); | ||
54 | } call_t; | ||
55 | |||
56 | struct ircomm_cb { | ||
57 | irda_queue_t queue; | ||
58 | magic_t magic; | ||
59 | |||
60 | notify_t notify; | ||
61 | call_t issue; | ||
62 | |||
63 | int state; | ||
64 | int line; /* Which TTY line we are using */ | ||
65 | |||
66 | struct tsap_cb *tsap; | ||
67 | struct lsap_cb *lsap; | ||
68 | |||
69 | __u8 dlsap_sel; /* Destination LSAP/TSAP selector */ | ||
70 | __u8 slsap_sel; /* Source LSAP/TSAP selector */ | ||
71 | |||
72 | __u32 saddr; /* Source device address (link we are using) */ | ||
73 | __u32 daddr; /* Destination device address */ | ||
74 | |||
75 | int max_header_size; /* Header space we must reserve for each frame */ | ||
76 | int max_data_size; /* The amount of data we can fill in each frame */ | ||
77 | |||
78 | LOCAL_FLOW flow_status; /* Used by ircomm_lmp */ | ||
79 | int pkt_count; /* Number of frames we have sent to IrLAP */ | ||
80 | |||
81 | __u8 service_type; | ||
82 | }; | ||
83 | |||
84 | extern hashbin_t *ircomm; | ||
85 | |||
86 | struct ircomm_cb *ircomm_open(notify_t *notify, __u8 service_type, int line); | ||
87 | int ircomm_close(struct ircomm_cb *self); | ||
88 | |||
89 | int ircomm_data_request(struct ircomm_cb *self, struct sk_buff *skb); | ||
90 | void ircomm_data_indication(struct ircomm_cb *self, struct sk_buff *skb); | ||
91 | void ircomm_process_data(struct ircomm_cb *self, struct sk_buff *skb); | ||
92 | int ircomm_control_request(struct ircomm_cb *self, struct sk_buff *skb); | ||
93 | int ircomm_connect_request(struct ircomm_cb *self, __u8 dlsap_sel, | ||
94 | __u32 saddr, __u32 daddr, struct sk_buff *skb, | ||
95 | __u8 service_type); | ||
96 | void ircomm_connect_indication(struct ircomm_cb *self, struct sk_buff *skb, | ||
97 | struct ircomm_info *info); | ||
98 | void ircomm_connect_confirm(struct ircomm_cb *self, struct sk_buff *skb, | ||
99 | struct ircomm_info *info); | ||
100 | int ircomm_connect_response(struct ircomm_cb *self, struct sk_buff *userdata); | ||
101 | int ircomm_disconnect_request(struct ircomm_cb *self, struct sk_buff *userdata); | ||
102 | void ircomm_disconnect_indication(struct ircomm_cb *self, struct sk_buff *skb, | ||
103 | struct ircomm_info *info); | ||
104 | void ircomm_flow_request(struct ircomm_cb *self, LOCAL_FLOW flow); | ||
105 | |||
106 | #define ircomm_is_connected(self) (self->state == IRCOMM_CONN) | ||
107 | |||
108 | #endif | ||
diff --git a/include/net/irda/ircomm_event.h b/include/net/irda/ircomm_event.h new file mode 100644 index 000000000000..c290447872d1 --- /dev/null +++ b/include/net/irda/ircomm_event.h | |||
@@ -0,0 +1,85 @@ | |||
1 | /********************************************************************* | ||
2 | * | ||
3 | * Filename: ircomm_event.h | ||
4 | * Version: | ||
5 | * Description: | ||
6 | * Status: Experimental. | ||
7 | * Author: Dag Brattli <dagb@cs.uit.no> | ||
8 | * Created at: Sun Jun 6 23:51:13 1999 | ||
9 | * Modified at: Thu Jun 10 08:36:25 1999 | ||
10 | * Modified by: Dag Brattli <dagb@cs.uit.no> | ||
11 | * | ||
12 | * Copyright (c) 1999 Dag Brattli, All Rights Reserved. | ||
13 | * | ||
14 | * This program is free software; you can redistribute it and/or | ||
15 | * modify it under the terms of the GNU General Public License as | ||
16 | * published by the Free Software Foundation; either version 2 of | ||
17 | * the License, or (at your option) any later version. | ||
18 | * | ||
19 | * This program is distributed in the hope that it will be useful, | ||
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
22 | * GNU General Public License for more details. | ||
23 | * | ||
24 | * You should have received a copy of the GNU General Public License | ||
25 | * along with this program; if not, write to the Free Software | ||
26 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, | ||
27 | * MA 02111-1307 USA | ||
28 | * | ||
29 | ********************************************************************/ | ||
30 | |||
31 | #ifndef IRCOMM_EVENT_H | ||
32 | #define IRCOMM_EVENT_H | ||
33 | |||
34 | #include <net/irda/irmod.h> | ||
35 | |||
36 | typedef enum { | ||
37 | IRCOMM_IDLE, | ||
38 | IRCOMM_WAITI, | ||
39 | IRCOMM_WAITR, | ||
40 | IRCOMM_CONN, | ||
41 | } IRCOMM_STATE; | ||
42 | |||
43 | /* IrCOMM Events */ | ||
44 | typedef enum { | ||
45 | IRCOMM_CONNECT_REQUEST, | ||
46 | IRCOMM_CONNECT_RESPONSE, | ||
47 | IRCOMM_TTP_CONNECT_INDICATION, | ||
48 | IRCOMM_LMP_CONNECT_INDICATION, | ||
49 | IRCOMM_TTP_CONNECT_CONFIRM, | ||
50 | IRCOMM_LMP_CONNECT_CONFIRM, | ||
51 | |||
52 | IRCOMM_LMP_DISCONNECT_INDICATION, | ||
53 | IRCOMM_TTP_DISCONNECT_INDICATION, | ||
54 | IRCOMM_DISCONNECT_REQUEST, | ||
55 | |||
56 | IRCOMM_TTP_DATA_INDICATION, | ||
57 | IRCOMM_LMP_DATA_INDICATION, | ||
58 | IRCOMM_DATA_REQUEST, | ||
59 | IRCOMM_CONTROL_REQUEST, | ||
60 | IRCOMM_CONTROL_INDICATION, | ||
61 | } IRCOMM_EVENT; | ||
62 | |||
63 | /* | ||
64 | * Used for passing information through the state-machine | ||
65 | */ | ||
66 | struct ircomm_info { | ||
67 | __u32 saddr; /* Source device address */ | ||
68 | __u32 daddr; /* Destination device address */ | ||
69 | __u8 dlsap_sel; | ||
70 | LM_REASON reason; /* Reason for disconnect */ | ||
71 | __u32 max_data_size; | ||
72 | __u32 max_header_size; | ||
73 | |||
74 | struct qos_info *qos; | ||
75 | }; | ||
76 | |||
77 | extern char *ircomm_state[]; | ||
78 | |||
79 | struct ircomm_cb; /* Forward decl. */ | ||
80 | |||
81 | int ircomm_do_event(struct ircomm_cb *self, IRCOMM_EVENT event, | ||
82 | struct sk_buff *skb, struct ircomm_info *info); | ||
83 | void ircomm_next_state(struct ircomm_cb *self, IRCOMM_STATE state); | ||
84 | |||
85 | #endif | ||
diff --git a/include/net/irda/ircomm_lmp.h b/include/net/irda/ircomm_lmp.h new file mode 100644 index 000000000000..ae02106be590 --- /dev/null +++ b/include/net/irda/ircomm_lmp.h | |||
@@ -0,0 +1,38 @@ | |||
1 | /********************************************************************* | ||
2 | * | ||
3 | * Filename: ircomm_lmp.h | ||
4 | * Version: | ||
5 | * Description: | ||
6 | * Status: Experimental. | ||
7 | * Author: Dag Brattli <dagb@cs.uit.no> | ||
8 | * Created at: Wed Jun 9 10:06:07 1999 | ||
9 | * Modified at: Fri Aug 13 07:32:32 1999 | ||
10 | * Modified by: Dag Brattli <dagb@cs.uit.no> | ||
11 | * | ||
12 | * Copyright (c) 1999 Dag Brattli, All Rights Reserved. | ||
13 | * | ||
14 | * This program is free software; you can redistribute it and/or | ||
15 | * modify it under the terms of the GNU General Public License as | ||
16 | * published by the Free Software Foundation; either version 2 of | ||
17 | * the License, or (at your option) any later version. | ||
18 | * | ||
19 | * This program is distributed in the hope that it will be useful, | ||
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
22 | * GNU General Public License for more details. | ||
23 | * | ||
24 | * You should have received a copy of the GNU General Public License | ||
25 | * along with this program; if not, write to the Free Software | ||
26 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, | ||
27 | * MA 02111-1307 USA | ||
28 | * | ||
29 | ********************************************************************/ | ||
30 | |||
31 | #ifndef IRCOMM_LMP_H | ||
32 | #define IRCOMM_LMP_H | ||
33 | |||
34 | #include <net/irda/ircomm_core.h> | ||
35 | |||
36 | int ircomm_open_lsap(struct ircomm_cb *self); | ||
37 | |||
38 | #endif | ||
diff --git a/include/net/irda/ircomm_param.h b/include/net/irda/ircomm_param.h new file mode 100644 index 000000000000..e6678800c41f --- /dev/null +++ b/include/net/irda/ircomm_param.h | |||
@@ -0,0 +1,149 @@ | |||
1 | /********************************************************************* | ||
2 | * | ||
3 | * Filename: ircomm_param.h | ||
4 | * Version: 1.0 | ||
5 | * Description: Parameter handling for the IrCOMM protocol | ||
6 | * Status: Experimental. | ||
7 | * Author: Dag Brattli <dagb@cs.uit.no> | ||
8 | * Created at: Mon Jun 7 08:47:28 1999 | ||
9 | * Modified at: Wed Aug 25 13:46:33 1999 | ||
10 | * Modified by: Dag Brattli <dagb@cs.uit.no> | ||
11 | * | ||
12 | * Copyright (c) 1999 Dag Brattli, All Rights Reserved. | ||
13 | * | ||
14 | * This program is free software; you can redistribute it and/or | ||
15 | * modify it under the terms of the GNU General Public License as | ||
16 | * published by the Free Software Foundation; either version 2 of | ||
17 | * the License, or (at your option) any later version. | ||
18 | * | ||
19 | * This program is distributed in the hope that it will be useful, | ||
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
22 | * GNU General Public License for more details. | ||
23 | * | ||
24 | * You should have received a copy of the GNU General Public License | ||
25 | * along with this program; if not, write to the Free Software | ||
26 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, | ||
27 | * MA 02111-1307 USA | ||
28 | * | ||
29 | ********************************************************************/ | ||
30 | |||
31 | #ifndef IRCOMM_PARAMS_H | ||
32 | #define IRCOMM_PARAMS_H | ||
33 | |||
34 | #include <net/irda/parameters.h> | ||
35 | |||
36 | /* Parameters common to all service types */ | ||
37 | #define IRCOMM_SERVICE_TYPE 0x00 | ||
38 | #define IRCOMM_PORT_TYPE 0x01 /* Only used in LM-IAS */ | ||
39 | #define IRCOMM_PORT_NAME 0x02 /* Only used in LM-IAS */ | ||
40 | |||
41 | /* Parameters for both 3 wire and 9 wire */ | ||
42 | #define IRCOMM_DATA_RATE 0x10 | ||
43 | #define IRCOMM_DATA_FORMAT 0x11 | ||
44 | #define IRCOMM_FLOW_CONTROL 0x12 | ||
45 | #define IRCOMM_XON_XOFF 0x13 | ||
46 | #define IRCOMM_ENQ_ACK 0x14 | ||
47 | #define IRCOMM_LINE_STATUS 0x15 | ||
48 | #define IRCOMM_BREAK 0x16 | ||
49 | |||
50 | /* Parameters for 9 wire */ | ||
51 | #define IRCOMM_DTE 0x20 | ||
52 | #define IRCOMM_DCE 0x21 | ||
53 | #define IRCOMM_POLL 0x22 | ||
54 | |||
55 | /* Service type (details) */ | ||
56 | #define IRCOMM_3_WIRE_RAW 0x01 | ||
57 | #define IRCOMM_3_WIRE 0x02 | ||
58 | #define IRCOMM_9_WIRE 0x04 | ||
59 | #define IRCOMM_CENTRONICS 0x08 | ||
60 | |||
61 | /* Port type (details) */ | ||
62 | #define IRCOMM_SERIAL 0x00 | ||
63 | #define IRCOMM_PARALLEL 0x01 | ||
64 | |||
65 | /* Data format (details) */ | ||
66 | #define IRCOMM_WSIZE_5 0x00 | ||
67 | #define IRCOMM_WSIZE_6 0x01 | ||
68 | #define IRCOMM_WSIZE_7 0x02 | ||
69 | #define IRCOMM_WSIZE_8 0x03 | ||
70 | |||
71 | #define IRCOMM_1_STOP_BIT 0x00 | ||
72 | #define IRCOMM_2_STOP_BIT 0x04 /* 1.5 if char len 5 */ | ||
73 | |||
74 | #define IRCOMM_PARITY_DISABLE 0x00 | ||
75 | #define IRCOMM_PARITY_ENABLE 0x08 | ||
76 | |||
77 | #define IRCOMM_PARITY_ODD 0x00 | ||
78 | #define IRCOMM_PARITY_EVEN 0x10 | ||
79 | #define IRCOMM_PARITY_MARK 0x20 | ||
80 | #define IRCOMM_PARITY_SPACE 0x30 | ||
81 | |||
82 | /* Flow control */ | ||
83 | #define IRCOMM_XON_XOFF_IN 0x01 | ||
84 | #define IRCOMM_XON_XOFF_OUT 0x02 | ||
85 | #define IRCOMM_RTS_CTS_IN 0x04 | ||
86 | #define IRCOMM_RTS_CTS_OUT 0x08 | ||
87 | #define IRCOMM_DSR_DTR_IN 0x10 | ||
88 | #define IRCOMM_DSR_DTR_OUT 0x20 | ||
89 | #define IRCOMM_ENQ_ACK_IN 0x40 | ||
90 | #define IRCOMM_ENQ_ACK_OUT 0x80 | ||
91 | |||
92 | /* Line status */ | ||
93 | #define IRCOMM_OVERRUN_ERROR 0x02 | ||
94 | #define IRCOMM_PARITY_ERROR 0x04 | ||
95 | #define IRCOMM_FRAMING_ERROR 0x08 | ||
96 | |||
97 | /* DTE (Data terminal equipment) line settings */ | ||
98 | #define IRCOMM_DELTA_DTR 0x01 | ||
99 | #define IRCOMM_DELTA_RTS 0x02 | ||
100 | #define IRCOMM_DTR 0x04 | ||
101 | #define IRCOMM_RTS 0x08 | ||
102 | |||
103 | /* DCE (Data communications equipment) line settings */ | ||
104 | #define IRCOMM_DELTA_CTS 0x01 /* Clear to send has changed */ | ||
105 | #define IRCOMM_DELTA_DSR 0x02 /* Data set ready has changed */ | ||
106 | #define IRCOMM_DELTA_RI 0x04 /* Ring indicator has changed */ | ||
107 | #define IRCOMM_DELTA_CD 0x08 /* Carrier detect has changed */ | ||
108 | #define IRCOMM_CTS 0x10 /* Clear to send is high */ | ||
109 | #define IRCOMM_DSR 0x20 /* Data set ready is high */ | ||
110 | #define IRCOMM_RI 0x40 /* Ring indicator is high */ | ||
111 | #define IRCOMM_CD 0x80 /* Carrier detect is high */ | ||
112 | #define IRCOMM_DCE_DELTA_ANY 0x0f | ||
113 | |||
114 | /* | ||
115 | * Parameter state | ||
116 | */ | ||
117 | struct ircomm_params { | ||
118 | /* General control params */ | ||
119 | __u8 service_type; | ||
120 | __u8 port_type; | ||
121 | char port_name[32]; | ||
122 | |||
123 | /* Control params for 3- and 9-wire service type */ | ||
124 | __u32 data_rate; /* Data rate in bps */ | ||
125 | __u8 data_format; | ||
126 | __u8 flow_control; | ||
127 | char xonxoff[2]; | ||
128 | char enqack[2]; | ||
129 | __u8 line_status; | ||
130 | __u8 _break; | ||
131 | |||
132 | __u8 null_modem; | ||
133 | |||
134 | /* Control params for 9-wire service type */ | ||
135 | __u8 dte; | ||
136 | __u8 dce; | ||
137 | __u8 poll; | ||
138 | |||
139 | /* Control params for Centronics service type */ | ||
140 | }; | ||
141 | |||
142 | struct ircomm_tty_cb; /* Forward decl. */ | ||
143 | |||
144 | int ircomm_param_request(struct ircomm_tty_cb *self, __u8 pi, int flush); | ||
145 | |||
146 | extern pi_param_info_t ircomm_param_info; | ||
147 | |||
148 | #endif /* IRCOMM_PARAMS_H */ | ||
149 | |||
diff --git a/include/net/irda/ircomm_ttp.h b/include/net/irda/ircomm_ttp.h new file mode 100644 index 000000000000..403081ed725c --- /dev/null +++ b/include/net/irda/ircomm_ttp.h | |||
@@ -0,0 +1,39 @@ | |||
1 | /********************************************************************* | ||
2 | * | ||
3 | * Filename: ircomm_ttp.h | ||
4 | * Version: | ||
5 | * Description: | ||
6 | * Status: Experimental. | ||
7 | * Author: Dag Brattli <dagb@cs.uit.no> | ||
8 | * Created at: Wed Jun 9 10:06:07 1999 | ||
9 | * Modified at: Fri Aug 13 07:32:22 1999 | ||
10 | * Modified by: Dag Brattli <dagb@cs.uit.no> | ||
11 | * | ||
12 | * Copyright (c) 1999 Dag Brattli, All Rights Reserved. | ||
13 | * | ||
14 | * This program is free software; you can redistribute it and/or | ||
15 | * modify it under the terms of the GNU General Public License as | ||
16 | * published by the Free Software Foundation; either version 2 of | ||
17 | * the License, or (at your option) any later version. | ||
18 | * | ||
19 | * This program is distributed in the hope that it will be useful, | ||
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
22 | * GNU General Public License for more details. | ||
23 | * | ||
24 | * You should have received a copy of the GNU General Public License | ||
25 | * along with this program; if not, write to the Free Software | ||
26 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, | ||
27 | * MA 02111-1307 USA | ||
28 | * | ||
29 | ********************************************************************/ | ||
30 | |||
31 | #ifndef IRCOMM_TTP_H | ||
32 | #define IRCOMM_TTP_H | ||
33 | |||
34 | #include <net/irda/ircomm_core.h> | ||
35 | |||
36 | int ircomm_open_tsap(struct ircomm_cb *self); | ||
37 | |||
38 | #endif | ||
39 | |||
diff --git a/include/net/irda/ircomm_tty.h b/include/net/irda/ircomm_tty.h new file mode 100644 index 000000000000..87699cb4ef8c --- /dev/null +++ b/include/net/irda/ircomm_tty.h | |||
@@ -0,0 +1,139 @@ | |||
1 | /********************************************************************* | ||
2 | * | ||
3 | * Filename: ircomm_tty.h | ||
4 | * Version: | ||
5 | * Description: | ||
6 | * Status: Experimental. | ||
7 | * Author: Dag Brattli <dagb@cs.uit.no> | ||
8 | * Created at: Sun Jun 6 23:24:22 1999 | ||
9 | * Modified at: Fri Jan 28 13:16:57 2000 | ||
10 | * Modified by: Dag Brattli <dagb@cs.uit.no> | ||
11 | * | ||
12 | * Copyright (c) 1999-2000 Dag Brattli, All Rights Reserved. | ||
13 | * | ||
14 | * This program is free software; you can redistribute it and/or | ||
15 | * modify it under the terms of the GNU General Public License as | ||
16 | * published by the Free Software Foundation; either version 2 of | ||
17 | * the License, or (at your option) any later version. | ||
18 | * | ||
19 | * This program is distributed in the hope that it will be useful, | ||
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
22 | * GNU General Public License for more details. | ||
23 | * | ||
24 | * You should have received a copy of the GNU General Public License | ||
25 | * along with this program; if not, write to the Free Software | ||
26 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, | ||
27 | * MA 02111-1307 USA | ||
28 | * | ||
29 | ********************************************************************/ | ||
30 | |||
31 | #ifndef IRCOMM_TTY_H | ||
32 | #define IRCOMM_TTY_H | ||
33 | |||
34 | #include <linux/serial.h> | ||
35 | #include <linux/termios.h> | ||
36 | #include <linux/timer.h> | ||
37 | #include <linux/tty.h> /* struct tty_struct */ | ||
38 | |||
39 | #include <net/irda/irias_object.h> | ||
40 | #include <net/irda/ircomm_core.h> | ||
41 | #include <net/irda/ircomm_param.h> | ||
42 | |||
43 | #define IRCOMM_TTY_PORTS 32 | ||
44 | #define IRCOMM_TTY_MAGIC 0x3432 | ||
45 | #define IRCOMM_TTY_MAJOR 161 | ||
46 | #define IRCOMM_TTY_MINOR 0 | ||
47 | |||
48 | /* This is used as an initial value to max_header_size before the proper | ||
49 | * value is filled in (5 for ttp, 4 for lmp). This allow us to detect | ||
50 | * the state of the underlying connection. - Jean II */ | ||
51 | #define IRCOMM_TTY_HDR_UNINITIALISED 16 | ||
52 | /* Same for payload size. See qos.c for the smallest max data size */ | ||
53 | #define IRCOMM_TTY_DATA_UNINITIALISED (64 - IRCOMM_TTY_HDR_UNINITIALISED) | ||
54 | |||
55 | /* Those are really defined in include/linux/serial.h - Jean II */ | ||
56 | #define ASYNC_B_INITIALIZED 31 /* Serial port was initialized */ | ||
57 | #define ASYNC_B_NORMAL_ACTIVE 29 /* Normal device is active */ | ||
58 | #define ASYNC_B_CLOSING 27 /* Serial port is closing */ | ||
59 | |||
60 | /* | ||
61 | * IrCOMM TTY driver state | ||
62 | */ | ||
63 | struct ircomm_tty_cb { | ||
64 | irda_queue_t queue; /* Must be first */ | ||
65 | magic_t magic; | ||
66 | |||
67 | int state; /* Connect state */ | ||
68 | |||
69 | struct tty_struct *tty; | ||
70 | struct ircomm_cb *ircomm; /* IrCOMM layer instance */ | ||
71 | |||
72 | struct sk_buff *tx_skb; /* Transmit buffer */ | ||
73 | struct sk_buff *ctrl_skb; /* Control data buffer */ | ||
74 | |||
75 | /* Parameters */ | ||
76 | struct ircomm_params settings; | ||
77 | |||
78 | __u8 service_type; /* The service that we support */ | ||
79 | int client; /* True if we are a client */ | ||
80 | LOCAL_FLOW flow; /* IrTTP flow status */ | ||
81 | |||
82 | int line; | ||
83 | unsigned long flags; | ||
84 | |||
85 | __u8 dlsap_sel; | ||
86 | __u8 slsap_sel; | ||
87 | |||
88 | __u32 saddr; | ||
89 | __u32 daddr; | ||
90 | |||
91 | __u32 max_data_size; /* Max data we can transmit in one packet */ | ||
92 | __u32 max_header_size; /* The amount of header space we must reserve */ | ||
93 | __u32 tx_data_size; /* Max data size of current tx_skb */ | ||
94 | |||
95 | struct iriap_cb *iriap; /* Instance used for querying remote IAS */ | ||
96 | struct ias_object* obj; | ||
97 | void *skey; | ||
98 | void *ckey; | ||
99 | |||
100 | wait_queue_head_t open_wait; | ||
101 | wait_queue_head_t close_wait; | ||
102 | struct timer_list watchdog_timer; | ||
103 | struct work_struct tqueue; | ||
104 | |||
105 | unsigned short close_delay; | ||
106 | unsigned short closing_wait; /* time to wait before closing */ | ||
107 | |||
108 | int open_count; | ||
109 | int blocked_open; /* # of blocked opens */ | ||
110 | |||
111 | /* Protect concurent access to : | ||
112 | * o self->open_count | ||
113 | * o self->ctrl_skb | ||
114 | * o self->tx_skb | ||
115 | * Maybe other things may gain to be protected as well... | ||
116 | * Jean II */ | ||
117 | spinlock_t spinlock; | ||
118 | }; | ||
119 | |||
120 | void ircomm_tty_start(struct tty_struct *tty); | ||
121 | void ircomm_tty_check_modem_status(struct ircomm_tty_cb *self); | ||
122 | |||
123 | extern int ircomm_tty_tiocmget(struct tty_struct *tty, struct file *file); | ||
124 | extern int ircomm_tty_tiocmset(struct tty_struct *tty, struct file *file, | ||
125 | unsigned int set, unsigned int clear); | ||
126 | extern int ircomm_tty_ioctl(struct tty_struct *tty, struct file *file, | ||
127 | unsigned int cmd, unsigned long arg); | ||
128 | extern void ircomm_tty_set_termios(struct tty_struct *tty, | ||
129 | struct termios *old_termios); | ||
130 | extern hashbin_t *ircomm_tty; | ||
131 | |||
132 | #endif | ||
133 | |||
134 | |||
135 | |||
136 | |||
137 | |||
138 | |||
139 | |||
diff --git a/include/net/irda/ircomm_tty_attach.h b/include/net/irda/ircomm_tty_attach.h new file mode 100644 index 000000000000..f91a5695aa44 --- /dev/null +++ b/include/net/irda/ircomm_tty_attach.h | |||
@@ -0,0 +1,94 @@ | |||
1 | /********************************************************************* | ||
2 | * | ||
3 | * Filename: ircomm_tty_attach.h | ||
4 | * Version: | ||
5 | * Description: | ||
6 | * Status: Experimental. | ||
7 | * Author: Dag Brattli <dagb@cs.uit.no> | ||
8 | * Created at: Wed Jun 9 15:55:18 1999 | ||
9 | * Modified at: Fri Dec 10 21:04:55 1999 | ||
10 | * Modified by: Dag Brattli <dagb@cs.uit.no> | ||
11 | * | ||
12 | * Copyright (c) 1999 Dag Brattli, All Rights Reserved. | ||
13 | * | ||
14 | * This program is free software; you can redistribute it and/or | ||
15 | * modify it under the terms of the GNU General Public License as | ||
16 | * published by the Free Software Foundation; either version 2 of | ||
17 | * the License, or (at your option) any later version. | ||
18 | * | ||
19 | * This program is distributed in the hope that it will be useful, | ||
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
22 | * GNU General Public License for more details. | ||
23 | * | ||
24 | * You should have received a copy of the GNU General Public License | ||
25 | * along with this program; if not, write to the Free Software | ||
26 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, | ||
27 | * MA 02111-1307 USA | ||
28 | * | ||
29 | ********************************************************************/ | ||
30 | |||
31 | #ifndef IRCOMM_TTY_ATTACH_H | ||
32 | #define IRCOMM_TTY_ATTACH_H | ||
33 | |||
34 | #include <net/irda/ircomm_tty.h> | ||
35 | |||
36 | typedef enum { | ||
37 | IRCOMM_TTY_IDLE, | ||
38 | IRCOMM_TTY_SEARCH, | ||
39 | IRCOMM_TTY_QUERY_PARAMETERS, | ||
40 | IRCOMM_TTY_QUERY_LSAP_SEL, | ||
41 | IRCOMM_TTY_SETUP, | ||
42 | IRCOMM_TTY_READY, | ||
43 | } IRCOMM_TTY_STATE; | ||
44 | |||
45 | /* IrCOMM TTY Events */ | ||
46 | typedef enum { | ||
47 | IRCOMM_TTY_ATTACH_CABLE, | ||
48 | IRCOMM_TTY_DETACH_CABLE, | ||
49 | IRCOMM_TTY_DATA_REQUEST, | ||
50 | IRCOMM_TTY_DATA_INDICATION, | ||
51 | IRCOMM_TTY_DISCOVERY_REQUEST, | ||
52 | IRCOMM_TTY_DISCOVERY_INDICATION, | ||
53 | IRCOMM_TTY_CONNECT_CONFIRM, | ||
54 | IRCOMM_TTY_CONNECT_INDICATION, | ||
55 | IRCOMM_TTY_DISCONNECT_REQUEST, | ||
56 | IRCOMM_TTY_DISCONNECT_INDICATION, | ||
57 | IRCOMM_TTY_WD_TIMER_EXPIRED, | ||
58 | IRCOMM_TTY_GOT_PARAMETERS, | ||
59 | IRCOMM_TTY_GOT_LSAPSEL, | ||
60 | } IRCOMM_TTY_EVENT; | ||
61 | |||
62 | /* Used for passing information through the state-machine */ | ||
63 | struct ircomm_tty_info { | ||
64 | __u32 saddr; /* Source device address */ | ||
65 | __u32 daddr; /* Destination device address */ | ||
66 | __u8 dlsap_sel; | ||
67 | }; | ||
68 | |||
69 | extern char *ircomm_state[]; | ||
70 | extern char *ircomm_tty_state[]; | ||
71 | |||
72 | int ircomm_tty_do_event(struct ircomm_tty_cb *self, IRCOMM_TTY_EVENT event, | ||
73 | struct sk_buff *skb, struct ircomm_tty_info *info); | ||
74 | |||
75 | |||
76 | int ircomm_tty_attach_cable(struct ircomm_tty_cb *self); | ||
77 | void ircomm_tty_detach_cable(struct ircomm_tty_cb *self); | ||
78 | void ircomm_tty_connect_confirm(void *instance, void *sap, | ||
79 | struct qos_info *qos, | ||
80 | __u32 max_sdu_size, | ||
81 | __u8 max_header_size, | ||
82 | struct sk_buff *skb); | ||
83 | void ircomm_tty_disconnect_indication(void *instance, void *sap, | ||
84 | LM_REASON reason, | ||
85 | struct sk_buff *skb); | ||
86 | void ircomm_tty_connect_indication(void *instance, void *sap, | ||
87 | struct qos_info *qos, | ||
88 | __u32 max_sdu_size, | ||
89 | __u8 max_header_size, | ||
90 | struct sk_buff *skb); | ||
91 | int ircomm_tty_send_initial_parameters(struct ircomm_tty_cb *self); | ||
92 | void ircomm_tty_link_established(struct ircomm_tty_cb *self); | ||
93 | |||
94 | #endif /* IRCOMM_TTY_ATTACH_H */ | ||
diff --git a/include/net/irda/irda.h b/include/net/irda/irda.h new file mode 100644 index 000000000000..05a840837fe7 --- /dev/null +++ b/include/net/irda/irda.h | |||
@@ -0,0 +1,117 @@ | |||
1 | /********************************************************************* | ||
2 | * | ||
3 | * Filename: irda.h | ||
4 | * Version: 1.0 | ||
5 | * Description: IrDA common include file for kernel internal use | ||
6 | * Status: Stable | ||
7 | * Author: Dag Brattli <dagb@cs.uit.no> | ||
8 | * Created at: Tue Dec 9 21:13:12 1997 | ||
9 | * Modified at: Fri Jan 28 13:16:32 2000 | ||
10 | * Modified by: Dag Brattli <dagb@cs.uit.no> | ||
11 | * | ||
12 | * Copyright (c) 1998-2000 Dag Brattli, All Rights Reserved. | ||
13 | * Copyright (c) 2000-2002 Jean Tourrilhes <jt@hpl.hp.com> | ||
14 | * | ||
15 | * This program is free software; you can redistribute it and/or | ||
16 | * modify it under the terms of the GNU General Public License as | ||
17 | * published by the Free Software Foundation; either version 2 of | ||
18 | * the License, or (at your option) any later version. | ||
19 | * | ||
20 | * Neither Dag Brattli nor University of Tromsų admit liability nor | ||
21 | * provide warranty for any of this software. This material is | ||
22 | * provided "AS-IS" and at no charge. | ||
23 | * | ||
24 | ********************************************************************/ | ||
25 | |||
26 | #ifndef NET_IRDA_H | ||
27 | #define NET_IRDA_H | ||
28 | |||
29 | #include <linux/config.h> | ||
30 | #include <linux/skbuff.h> /* struct sk_buff */ | ||
31 | #include <linux/kernel.h> | ||
32 | #include <linux/if.h> /* sa_family_t in <linux/irda.h> */ | ||
33 | #include <linux/irda.h> | ||
34 | |||
35 | typedef __u32 magic_t; | ||
36 | |||
37 | #ifndef TRUE | ||
38 | #define TRUE 1 | ||
39 | #endif | ||
40 | |||
41 | #ifndef FALSE | ||
42 | #define FALSE 0 | ||
43 | #endif | ||
44 | |||
45 | /* Hack to do small backoff when setting media busy in IrLAP */ | ||
46 | #ifndef SMALL | ||
47 | #define SMALL 5 | ||
48 | #endif | ||
49 | |||
50 | #ifndef IRDA_MIN /* Lets not mix this MIN with other header files */ | ||
51 | #define IRDA_MIN(a, b) (((a) < (b)) ? (a) : (b)) | ||
52 | #endif | ||
53 | |||
54 | #ifndef IRDA_ALIGN | ||
55 | # define IRDA_ALIGN __attribute__((aligned)) | ||
56 | #endif | ||
57 | #ifndef IRDA_PACK | ||
58 | # define IRDA_PACK __attribute__((packed)) | ||
59 | #endif | ||
60 | |||
61 | |||
62 | #ifdef CONFIG_IRDA_DEBUG | ||
63 | |||
64 | extern unsigned int irda_debug; | ||
65 | |||
66 | /* use 0 for production, 1 for verification, >2 for debug */ | ||
67 | #define IRDA_DEBUG_LEVEL 0 | ||
68 | |||
69 | #define IRDA_DEBUG(n, args...) \ | ||
70 | do { if (irda_debug >= (n)) \ | ||
71 | printk(KERN_DEBUG args); \ | ||
72 | } while (0) | ||
73 | #define IRDA_ASSERT(expr, func) \ | ||
74 | do { if(!(expr)) { \ | ||
75 | printk( "Assertion failed! %s:%s:%d %s\n", \ | ||
76 | __FILE__,__FUNCTION__,__LINE__,(#expr) ); \ | ||
77 | func } } while (0) | ||
78 | #define IRDA_ASSERT_LABEL(label) label | ||
79 | #else | ||
80 | #define IRDA_DEBUG(n, args...) do { } while (0) | ||
81 | #define IRDA_ASSERT(expr, func) do { (void)(expr); } while (0) | ||
82 | #define IRDA_ASSERT_LABEL(label) | ||
83 | #endif /* CONFIG_IRDA_DEBUG */ | ||
84 | |||
85 | #define IRDA_WARNING(args...) printk(KERN_WARNING args) | ||
86 | #define IRDA_MESSAGE(args...) printk(KERN_INFO args) | ||
87 | #define IRDA_ERROR(args...) printk(KERN_ERR args) | ||
88 | |||
89 | /* | ||
90 | * Magic numbers used by Linux-IrDA. Random numbers which must be unique to | ||
91 | * give the best protection | ||
92 | */ | ||
93 | |||
94 | #define IRTTY_MAGIC 0x2357 | ||
95 | #define LAP_MAGIC 0x1357 | ||
96 | #define LMP_MAGIC 0x4321 | ||
97 | #define LMP_LSAP_MAGIC 0x69333 | ||
98 | #define LMP_LAP_MAGIC 0x3432 | ||
99 | #define IRDA_DEVICE_MAGIC 0x63454 | ||
100 | #define IAS_MAGIC 0x007 | ||
101 | #define TTP_MAGIC 0x241169 | ||
102 | #define TTP_TSAP_MAGIC 0x4345 | ||
103 | #define IROBEX_MAGIC 0x341324 | ||
104 | #define HB_MAGIC 0x64534 | ||
105 | #define IRLAN_MAGIC 0x754 | ||
106 | #define IAS_OBJECT_MAGIC 0x34234 | ||
107 | #define IAS_ATTRIB_MAGIC 0x45232 | ||
108 | #define IRDA_TASK_MAGIC 0x38423 | ||
109 | |||
110 | #define IAS_DEVICE_ID 0x0000 /* Defined by IrDA, IrLMP section 4.1 (page 68) */ | ||
111 | #define IAS_PNP_ID 0xd342 | ||
112 | #define IAS_OBEX_ID 0x34323 | ||
113 | #define IAS_IRLAN_ID 0x34234 | ||
114 | #define IAS_IRCOMM_ID 0x2343 | ||
115 | #define IAS_IRLPT_ID 0x9876 | ||
116 | |||
117 | #endif /* NET_IRDA_H */ | ||
diff --git a/include/net/irda/irda_device.h b/include/net/irda/irda_device.h new file mode 100644 index 000000000000..3b216f186f18 --- /dev/null +++ b/include/net/irda/irda_device.h | |||
@@ -0,0 +1,301 @@ | |||
1 | /********************************************************************* | ||
2 | * | ||
3 | * Filename: irda_device.h | ||
4 | * Version: 0.9 | ||
5 | * Description: Contains various declarations used by the drivers | ||
6 | * Status: Experimental. | ||
7 | * Author: Dag Brattli <dagb@cs.uit.no> | ||
8 | * Created at: Tue Apr 14 12:41:42 1998 | ||
9 | * Modified at: Mon Mar 20 09:08:57 2000 | ||
10 | * Modified by: Dag Brattli <dagb@cs.uit.no> | ||
11 | * | ||
12 | * Copyright (c) 1999-2000 Dag Brattli, All Rights Reserved. | ||
13 | * Copyright (c) 1998 Thomas Davis, <ratbert@radiks.net>, | ||
14 | * Copyright (c) 2000-2002 Jean Tourrilhes <jt@hpl.hp.com> | ||
15 | * | ||
16 | * This program is free software; you can redistribute it and/or | ||
17 | * modify it under the terms of the GNU General Public License as | ||
18 | * published by the Free Software Foundation; either version 2 of | ||
19 | * the License, or (at your option) any later version. | ||
20 | * | ||
21 | * This program is distributed in the hope that it will be useful, | ||
22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
24 | * GNU General Public License for more details. | ||
25 | * | ||
26 | * You should have received a copy of the GNU General Public License | ||
27 | * along with this program; if not, write to the Free Software | ||
28 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, | ||
29 | * MA 02111-1307 USA | ||
30 | * | ||
31 | ********************************************************************/ | ||
32 | |||
33 | /* | ||
34 | * This header contains all the IrDA definitions a driver really | ||
35 | * needs, and therefore the driver should not need to include | ||
36 | * any other IrDA headers - Jean II | ||
37 | */ | ||
38 | |||
39 | #ifndef IRDA_DEVICE_H | ||
40 | #define IRDA_DEVICE_H | ||
41 | |||
42 | #include <linux/config.h> | ||
43 | #include <linux/tty.h> | ||
44 | #include <linux/netdevice.h> | ||
45 | #include <linux/spinlock.h> | ||
46 | #include <linux/skbuff.h> /* struct sk_buff */ | ||
47 | #include <linux/irda.h> | ||
48 | #include <linux/types.h> | ||
49 | |||
50 | #include <net/pkt_sched.h> | ||
51 | #include <net/irda/irda.h> | ||
52 | #include <net/irda/qos.h> /* struct qos_info */ | ||
53 | #include <net/irda/irqueue.h> /* irda_queue_t */ | ||
54 | |||
55 | /* A few forward declarations (to make compiler happy) */ | ||
56 | struct irlap_cb; | ||
57 | |||
58 | /* Some non-standard interface flags (should not conflict with any in if.h) */ | ||
59 | #define IFF_SIR 0x0001 /* Supports SIR speeds */ | ||
60 | #define IFF_MIR 0x0002 /* Supports MIR speeds */ | ||
61 | #define IFF_FIR 0x0004 /* Supports FIR speeds */ | ||
62 | #define IFF_VFIR 0x0008 /* Supports VFIR speeds */ | ||
63 | #define IFF_PIO 0x0010 /* Supports PIO transfer of data */ | ||
64 | #define IFF_DMA 0x0020 /* Supports DMA transfer of data */ | ||
65 | #define IFF_SHM 0x0040 /* Supports shared memory data transfers */ | ||
66 | #define IFF_DONGLE 0x0080 /* Interface has a dongle attached */ | ||
67 | #define IFF_AIR 0x0100 /* Supports Advanced IR (AIR) standards */ | ||
68 | |||
69 | #define IO_XMIT 0x01 | ||
70 | #define IO_RECV 0x02 | ||
71 | |||
72 | typedef enum { | ||
73 | IRDA_IRLAP, /* IrDA mode, and deliver to IrLAP */ | ||
74 | IRDA_RAW, /* IrDA mode */ | ||
75 | SHARP_ASK, | ||
76 | TV_REMOTE, /* Also known as Consumer Electronics IR */ | ||
77 | } INFRARED_MODE; | ||
78 | |||
79 | typedef enum { | ||
80 | IRDA_TASK_INIT, /* All tasks are initialized with this state */ | ||
81 | IRDA_TASK_DONE, /* Signals that the task is finished */ | ||
82 | IRDA_TASK_WAIT, | ||
83 | IRDA_TASK_WAIT1, | ||
84 | IRDA_TASK_WAIT2, | ||
85 | IRDA_TASK_WAIT3, | ||
86 | IRDA_TASK_CHILD_INIT, /* Initializing child task */ | ||
87 | IRDA_TASK_CHILD_WAIT, /* Waiting for child task to finish */ | ||
88 | IRDA_TASK_CHILD_DONE /* Child task is finished */ | ||
89 | } IRDA_TASK_STATE; | ||
90 | |||
91 | struct irda_task; | ||
92 | typedef int (*IRDA_TASK_CALLBACK) (struct irda_task *task); | ||
93 | |||
94 | struct irda_task { | ||
95 | irda_queue_t q; | ||
96 | magic_t magic; | ||
97 | |||
98 | IRDA_TASK_STATE state; | ||
99 | IRDA_TASK_CALLBACK function; | ||
100 | IRDA_TASK_CALLBACK finished; | ||
101 | |||
102 | struct irda_task *parent; | ||
103 | struct timer_list timer; | ||
104 | |||
105 | void *instance; /* Instance being called */ | ||
106 | void *param; /* Parameter to be used by instance */ | ||
107 | }; | ||
108 | |||
109 | /* Dongle info */ | ||
110 | struct dongle_reg; | ||
111 | typedef struct { | ||
112 | struct dongle_reg *issue; /* Registration info */ | ||
113 | struct net_device *dev; /* Device we are attached to */ | ||
114 | struct irda_task *speed_task; /* Task handling speed change */ | ||
115 | struct irda_task *reset_task; /* Task handling reset */ | ||
116 | __u32 speed; /* Current speed */ | ||
117 | |||
118 | /* Callbacks to the IrDA device driver */ | ||
119 | int (*set_mode)(struct net_device *, int mode); | ||
120 | int (*read)(struct net_device *dev, __u8 *buf, int len); | ||
121 | int (*write)(struct net_device *dev, __u8 *buf, int len); | ||
122 | int (*set_dtr_rts)(struct net_device *dev, int dtr, int rts); | ||
123 | } dongle_t; | ||
124 | |||
125 | /* Dongle registration info */ | ||
126 | struct dongle_reg { | ||
127 | irda_queue_t q; /* Must be first */ | ||
128 | IRDA_DONGLE type; | ||
129 | |||
130 | void (*open)(dongle_t *dongle, struct qos_info *qos); | ||
131 | void (*close)(dongle_t *dongle); | ||
132 | int (*reset)(struct irda_task *task); | ||
133 | int (*change_speed)(struct irda_task *task); | ||
134 | struct module *owner; | ||
135 | }; | ||
136 | |||
137 | /* | ||
138 | * Per-packet information we need to hide inside sk_buff | ||
139 | * (must not exceed 48 bytes, check with struct sk_buff) | ||
140 | */ | ||
141 | struct irda_skb_cb { | ||
142 | magic_t magic; /* Be sure that we can trust the information */ | ||
143 | __u32 next_speed; /* The Speed to be set *after* this frame */ | ||
144 | __u16 mtt; /* Minimum turn around time */ | ||
145 | __u16 xbofs; /* Number of xbofs required, used by SIR mode */ | ||
146 | __u16 next_xbofs; /* Number of xbofs required *after* this frame */ | ||
147 | void *context; /* May be used by drivers */ | ||
148 | void (*destructor)(struct sk_buff *skb); /* Used for flow control */ | ||
149 | __u16 xbofs_delay; /* Number of xbofs used for generating the mtt */ | ||
150 | __u8 line; /* Used by IrCOMM in IrLPT mode */ | ||
151 | }; | ||
152 | |||
153 | /* Chip specific info */ | ||
154 | typedef struct { | ||
155 | int cfg_base; /* Config register IO base */ | ||
156 | int sir_base; /* SIR IO base */ | ||
157 | int fir_base; /* FIR IO base */ | ||
158 | int mem_base; /* Shared memory base */ | ||
159 | int sir_ext; /* Length of SIR iobase */ | ||
160 | int fir_ext; /* Length of FIR iobase */ | ||
161 | int irq, irq2; /* Interrupts used */ | ||
162 | int dma, dma2; /* DMA channel(s) used */ | ||
163 | int fifo_size; /* FIFO size */ | ||
164 | int irqflags; /* interrupt flags (ie, SA_SHIRQ|SA_INTERRUPT) */ | ||
165 | int direction; /* Link direction, used by some FIR drivers */ | ||
166 | int enabled; /* Powered on? */ | ||
167 | int suspended; /* Suspended by APM */ | ||
168 | __u32 speed; /* Currently used speed */ | ||
169 | __u32 new_speed; /* Speed we must change to when Tx is finished */ | ||
170 | int dongle_id; /* Dongle or transceiver currently used */ | ||
171 | } chipio_t; | ||
172 | |||
173 | /* IO buffer specific info (inspired by struct sk_buff) */ | ||
174 | typedef struct { | ||
175 | int state; /* Receiving state (transmit state not used) */ | ||
176 | int in_frame; /* True if receiving frame */ | ||
177 | |||
178 | __u8 *head; /* start of buffer */ | ||
179 | __u8 *data; /* start of data in buffer */ | ||
180 | |||
181 | int len; /* current length of data */ | ||
182 | int truesize; /* total allocated size of buffer */ | ||
183 | __u16 fcs; | ||
184 | |||
185 | struct sk_buff *skb; /* ZeroCopy Rx in async_unwrap_char() */ | ||
186 | } iobuff_t; | ||
187 | |||
188 | /* Maximum SIR frame (skb) that we expect to receive *unwrapped*. | ||
189 | * Max LAP MTU (I field) is 2048 bytes max (IrLAP 1.1, chapt 6.6.5, p40). | ||
190 | * Max LAP header is 2 bytes (for now). | ||
191 | * Max CRC is 2 bytes at SIR, 4 bytes at FIR. | ||
192 | * Need 1 byte for skb_reserve() to align IP header for IrLAN. | ||
193 | * Add a few extra bytes just to be safe (buffer is power of two anyway) | ||
194 | * Jean II */ | ||
195 | #define IRDA_SKB_MAX_MTU 2064 | ||
196 | /* Maximum SIR frame that we expect to send, wrapped (i.e. with XBOFS | ||
197 | * and escaped characters on top of above). */ | ||
198 | #define IRDA_SIR_MAX_FRAME 4269 | ||
199 | |||
200 | /* The SIR unwrapper async_unwrap_char() will use a Rx-copy-break mechanism | ||
201 | * when using the optional ZeroCopy Rx, where only small frames are memcpy | ||
202 | * to a smaller skb to save memory. This is the threshold under which copy | ||
203 | * will happen (and over which it won't happen). | ||
204 | * Some FIR drivers may use this #define as well... | ||
205 | * This is the same value as various Ethernet drivers. - Jean II */ | ||
206 | #define IRDA_RX_COPY_THRESHOLD 256 | ||
207 | |||
208 | /* Function prototypes */ | ||
209 | int irda_device_init(void); | ||
210 | void irda_device_cleanup(void); | ||
211 | |||
212 | /* IrLAP entry points used by the drivers. | ||
213 | * We declare them here to avoid the driver pulling a whole bunch stack | ||
214 | * headers they don't really need - Jean II */ | ||
215 | struct irlap_cb *irlap_open(struct net_device *dev, struct qos_info *qos, | ||
216 | const char *hw_name); | ||
217 | void irlap_close(struct irlap_cb *self); | ||
218 | |||
219 | /* Interface to be uses by IrLAP */ | ||
220 | void irda_device_set_media_busy(struct net_device *dev, int status); | ||
221 | int irda_device_is_media_busy(struct net_device *dev); | ||
222 | int irda_device_is_receiving(struct net_device *dev); | ||
223 | |||
224 | /* Interface for internal use */ | ||
225 | static inline int irda_device_txqueue_empty(const struct net_device *dev) | ||
226 | { | ||
227 | return (skb_queue_len(&dev->qdisc->q) == 0); | ||
228 | } | ||
229 | int irda_device_set_raw_mode(struct net_device* self, int status); | ||
230 | struct net_device *alloc_irdadev(int sizeof_priv); | ||
231 | |||
232 | /* Dongle interface */ | ||
233 | void irda_device_unregister_dongle(struct dongle_reg *dongle); | ||
234 | int irda_device_register_dongle(struct dongle_reg *dongle); | ||
235 | dongle_t *irda_device_dongle_init(struct net_device *dev, int type); | ||
236 | int irda_device_dongle_cleanup(dongle_t *dongle); | ||
237 | |||
238 | #ifdef CONFIG_ISA | ||
239 | void irda_setup_dma(int channel, dma_addr_t buffer, int count, int mode); | ||
240 | #endif | ||
241 | |||
242 | void irda_task_delete(struct irda_task *task); | ||
243 | struct irda_task *irda_task_execute(void *instance, | ||
244 | IRDA_TASK_CALLBACK function, | ||
245 | IRDA_TASK_CALLBACK finished, | ||
246 | struct irda_task *parent, void *param); | ||
247 | void irda_task_next_state(struct irda_task *task, IRDA_TASK_STATE state); | ||
248 | |||
249 | /* | ||
250 | * Function irda_get_mtt (skb) | ||
251 | * | ||
252 | * Utility function for getting the minimum turnaround time out of | ||
253 | * the skb, where it has been hidden in the cb field. | ||
254 | */ | ||
255 | static inline __u16 irda_get_mtt(const struct sk_buff *skb) | ||
256 | { | ||
257 | const struct irda_skb_cb *cb = (const struct irda_skb_cb *) skb->cb; | ||
258 | return (cb->magic == LAP_MAGIC) ? cb->mtt : 10000; | ||
259 | } | ||
260 | |||
261 | /* | ||
262 | * Function irda_get_next_speed (skb) | ||
263 | * | ||
264 | * Extract the speed that should be set *after* this frame from the skb | ||
265 | * | ||
266 | * Note : return -1 for user space frames | ||
267 | */ | ||
268 | static inline __u32 irda_get_next_speed(const struct sk_buff *skb) | ||
269 | { | ||
270 | const struct irda_skb_cb *cb = (const struct irda_skb_cb *) skb->cb; | ||
271 | return (cb->magic == LAP_MAGIC) ? cb->next_speed : -1; | ||
272 | } | ||
273 | |||
274 | /* | ||
275 | * Function irda_get_next_xbofs (skb) | ||
276 | * | ||
277 | * Extract the xbofs that should be set for this frame from the skb | ||
278 | * | ||
279 | * Note : default to 10 for user space frames | ||
280 | */ | ||
281 | static inline __u16 irda_get_xbofs(const struct sk_buff *skb) | ||
282 | { | ||
283 | const struct irda_skb_cb *cb = (const struct irda_skb_cb *) skb->cb; | ||
284 | return (cb->magic == LAP_MAGIC) ? cb->xbofs : 10; | ||
285 | } | ||
286 | |||
287 | /* | ||
288 | * Function irda_get_next_xbofs (skb) | ||
289 | * | ||
290 | * Extract the xbofs that should be set *after* this frame from the skb | ||
291 | * | ||
292 | * Note : return -1 for user space frames | ||
293 | */ | ||
294 | static inline __u16 irda_get_next_xbofs(const struct sk_buff *skb) | ||
295 | { | ||
296 | const struct irda_skb_cb *cb = (const struct irda_skb_cb *) skb->cb; | ||
297 | return (cb->magic == LAP_MAGIC) ? cb->next_xbofs : -1; | ||
298 | } | ||
299 | #endif /* IRDA_DEVICE_H */ | ||
300 | |||
301 | |||
diff --git a/include/net/irda/iriap.h b/include/net/irda/iriap.h new file mode 100644 index 000000000000..2007c5a0a43f --- /dev/null +++ b/include/net/irda/iriap.h | |||
@@ -0,0 +1,108 @@ | |||
1 | /********************************************************************* | ||
2 | * | ||
3 | * Filename: iriap.h | ||
4 | * Version: 0.5 | ||
5 | * Description: Information Access Protocol (IAP) | ||
6 | * Status: Experimental. | ||
7 | * Author: Dag Brattli <dagb@cs.uit.no> | ||
8 | * Created at: Thu Aug 21 00:02:07 1997 | ||
9 | * Modified at: Sat Dec 25 16:42:09 1999 | ||
10 | * Modified by: Dag Brattli <dagb@cs.uit.no> | ||
11 | * | ||
12 | * Copyright (c) 1997-1999 Dag Brattli <dagb@cs.uit.no>, | ||
13 | * All Rights Reserved. | ||
14 | * | ||
15 | * This program is free software; you can redistribute it and/or | ||
16 | * modify it under the terms of the GNU General Public License as | ||
17 | * published by the Free Software Foundation; either version 2 of | ||
18 | * the License, or (at your option) any later version. | ||
19 | * | ||
20 | * Neither Dag Brattli nor University of Tromsų admit liability nor | ||
21 | * provide warranty for any of this software. This material is | ||
22 | * provided "AS-IS" and at no charge. | ||
23 | * | ||
24 | ********************************************************************/ | ||
25 | |||
26 | #ifndef IRIAP_H | ||
27 | #define IRIAP_H | ||
28 | |||
29 | #include <linux/types.h> | ||
30 | #include <linux/skbuff.h> | ||
31 | |||
32 | #include <net/irda/iriap_event.h> | ||
33 | #include <net/irda/irias_object.h> | ||
34 | #include <net/irda/irqueue.h> /* irda_queue_t */ | ||
35 | #include <net/irda/timer.h> /* struct timer_list */ | ||
36 | |||
37 | #define IAP_LST 0x80 | ||
38 | #define IAP_ACK 0x40 | ||
39 | |||
40 | #define IAS_SERVER 0 | ||
41 | #define IAS_CLIENT 1 | ||
42 | |||
43 | /* IrIAP Op-codes */ | ||
44 | #define GET_INFO_BASE 0x01 | ||
45 | #define GET_OBJECTS 0x02 | ||
46 | #define GET_VALUE 0x03 | ||
47 | #define GET_VALUE_BY_CLASS 0x04 | ||
48 | #define GET_OBJECT_INFO 0x05 | ||
49 | #define GET_ATTRIB_NAMES 0x06 | ||
50 | |||
51 | #define IAS_SUCCESS 0 | ||
52 | #define IAS_CLASS_UNKNOWN 1 | ||
53 | #define IAS_ATTRIB_UNKNOWN 2 | ||
54 | #define IAS_DISCONNECT 10 | ||
55 | |||
56 | typedef void (*CONFIRM_CALLBACK)(int result, __u16 obj_id, | ||
57 | struct ias_value *value, void *priv); | ||
58 | |||
59 | struct iriap_cb { | ||
60 | irda_queue_t q; /* Must be first */ | ||
61 | magic_t magic; /* Magic cookie */ | ||
62 | |||
63 | int mode; /* Client or server */ | ||
64 | |||
65 | __u32 saddr; | ||
66 | __u32 daddr; | ||
67 | __u8 operation; | ||
68 | |||
69 | struct sk_buff *request_skb; | ||
70 | struct lsap_cb *lsap; | ||
71 | __u8 slsap_sel; | ||
72 | |||
73 | /* Client states */ | ||
74 | IRIAP_STATE client_state; | ||
75 | IRIAP_STATE call_state; | ||
76 | |||
77 | /* Server states */ | ||
78 | IRIAP_STATE server_state; | ||
79 | IRIAP_STATE r_connect_state; | ||
80 | |||
81 | CONFIRM_CALLBACK confirm; | ||
82 | void *priv; /* Used to identify client */ | ||
83 | |||
84 | __u8 max_header_size; | ||
85 | __u32 max_data_size; | ||
86 | |||
87 | struct timer_list watchdog_timer; | ||
88 | }; | ||
89 | |||
90 | int iriap_init(void); | ||
91 | void iriap_cleanup(void); | ||
92 | |||
93 | struct iriap_cb *iriap_open(__u8 slsap_sel, int mode, void *priv, | ||
94 | CONFIRM_CALLBACK callback); | ||
95 | void iriap_close(struct iriap_cb *self); | ||
96 | |||
97 | int iriap_getvaluebyclass_request(struct iriap_cb *self, | ||
98 | __u32 saddr, __u32 daddr, | ||
99 | char *name, char *attr); | ||
100 | void iriap_connect_request(struct iriap_cb *self); | ||
101 | void iriap_send_ack( struct iriap_cb *self); | ||
102 | void iriap_call_indication(struct iriap_cb *self, struct sk_buff *skb); | ||
103 | |||
104 | void iriap_register_server(void); | ||
105 | |||
106 | #endif | ||
107 | |||
108 | |||
diff --git a/include/net/irda/iriap_event.h b/include/net/irda/iriap_event.h new file mode 100644 index 000000000000..4ca3d2071b03 --- /dev/null +++ b/include/net/irda/iriap_event.h | |||
@@ -0,0 +1,85 @@ | |||
1 | /********************************************************************* | ||
2 | * | ||
3 | * Filename: iriap_event.h | ||
4 | * Version: | ||
5 | * Description: | ||
6 | * Status: Experimental. | ||
7 | * Author: Dag Brattli <dagb@cs.uit.no> | ||
8 | * Created at: Mon Aug 4 20:40:53 1997 | ||
9 | * Modified at: Sun Oct 31 22:02:54 1999 | ||
10 | * Modified by: Dag Brattli <dagb@cs.uit.no> | ||
11 | * | ||
12 | * Copyright (c) 1998-1999 Dag Brattli <dagb@cs.uit.no>, All Rights Reserved. | ||
13 | * | ||
14 | * This program is free software; you can redistribute it and/or | ||
15 | * modify it under the terms of the GNU General Public License as | ||
16 | * published by the Free Software Foundation; either version 2 of | ||
17 | * the License, or (at your option) any later version. | ||
18 | * | ||
19 | * Neither Dag Brattli nor University of Tromsų admit liability nor | ||
20 | * provide warranty for any of this software. This material is | ||
21 | * provided "AS-IS" and at no charge. | ||
22 | * | ||
23 | ********************************************************************/ | ||
24 | |||
25 | #ifndef IRIAP_FSM_H | ||
26 | #define IRIAP_FSM_H | ||
27 | |||
28 | /* Forward because of circular include dependecies */ | ||
29 | struct iriap_cb; | ||
30 | |||
31 | /* IrIAP states */ | ||
32 | typedef enum { | ||
33 | /* Client */ | ||
34 | S_DISCONNECT, | ||
35 | S_CONNECTING, | ||
36 | S_CALL, | ||
37 | |||
38 | /* S-Call */ | ||
39 | S_MAKE_CALL, | ||
40 | S_CALLING, | ||
41 | S_OUTSTANDING, | ||
42 | S_REPLYING, | ||
43 | S_WAIT_FOR_CALL, | ||
44 | S_WAIT_ACTIVE, | ||
45 | |||
46 | /* Server */ | ||
47 | R_DISCONNECT, | ||
48 | R_CALL, | ||
49 | |||
50 | /* R-Connect */ | ||
51 | R_WAITING, | ||
52 | R_WAIT_ACTIVE, | ||
53 | R_RECEIVING, | ||
54 | R_EXECUTE, | ||
55 | R_RETURNING, | ||
56 | } IRIAP_STATE; | ||
57 | |||
58 | typedef enum { | ||
59 | IAP_CALL_REQUEST, | ||
60 | IAP_CALL_REQUEST_GVBC, | ||
61 | IAP_CALL_RESPONSE, | ||
62 | IAP_RECV_F_LST, | ||
63 | IAP_LM_DISCONNECT_INDICATION, | ||
64 | IAP_LM_CONNECT_INDICATION, | ||
65 | IAP_LM_CONNECT_CONFIRM, | ||
66 | } IRIAP_EVENT; | ||
67 | |||
68 | void iriap_next_client_state (struct iriap_cb *self, IRIAP_STATE state); | ||
69 | void iriap_next_call_state (struct iriap_cb *self, IRIAP_STATE state); | ||
70 | void iriap_next_server_state (struct iriap_cb *self, IRIAP_STATE state); | ||
71 | void iriap_next_r_connect_state(struct iriap_cb *self, IRIAP_STATE state); | ||
72 | |||
73 | |||
74 | void iriap_do_client_event(struct iriap_cb *self, IRIAP_EVENT event, | ||
75 | struct sk_buff *skb); | ||
76 | void iriap_do_call_event (struct iriap_cb *self, IRIAP_EVENT event, | ||
77 | struct sk_buff *skb); | ||
78 | |||
79 | void iriap_do_server_event (struct iriap_cb *self, IRIAP_EVENT event, | ||
80 | struct sk_buff *skb); | ||
81 | void iriap_do_r_connect_event(struct iriap_cb *self, IRIAP_EVENT event, | ||
82 | struct sk_buff *skb); | ||
83 | |||
84 | #endif /* IRIAP_FSM_H */ | ||
85 | |||
diff --git a/include/net/irda/irias_object.h b/include/net/irda/irias_object.h new file mode 100644 index 000000000000..c41196b87955 --- /dev/null +++ b/include/net/irda/irias_object.h | |||
@@ -0,0 +1,108 @@ | |||
1 | /********************************************************************* | ||
2 | * | ||
3 | * Filename: irias_object.h | ||
4 | * Version: | ||
5 | * Description: | ||
6 | * Status: Experimental. | ||
7 | * Author: Dag Brattli <dagb@cs.uit.no> | ||
8 | * Created at: Thu Oct 1 22:49:50 1998 | ||
9 | * Modified at: Wed Dec 15 11:20:57 1999 | ||
10 | * Modified by: Dag Brattli <dagb@cs.uit.no> | ||
11 | * | ||
12 | * Copyright (c) 1998-1999 Dag Brattli, All Rights Reserved. | ||
13 | * | ||
14 | * This program is free software; you can redistribute it and/or | ||
15 | * modify it under the terms of the GNU General Public License as | ||
16 | * published by the Free Software Foundation; either version 2 of | ||
17 | * the License, or (at your option) any later version. | ||
18 | * | ||
19 | * Neither Dag Brattli nor University of Tromsų admit liability nor | ||
20 | * provide warranty for any of this software. This material is | ||
21 | * provided "AS-IS" and at no charge. | ||
22 | * | ||
23 | ********************************************************************/ | ||
24 | |||
25 | #ifndef LM_IAS_OBJECT_H | ||
26 | #define LM_IAS_OBJECT_H | ||
27 | |||
28 | #include <net/irda/irda.h> | ||
29 | #include <net/irda/irqueue.h> | ||
30 | |||
31 | /* LM-IAS Attribute types */ | ||
32 | #define IAS_MISSING 0 | ||
33 | #define IAS_INTEGER 1 | ||
34 | #define IAS_OCT_SEQ 2 | ||
35 | #define IAS_STRING 3 | ||
36 | |||
37 | /* Object ownership of attributes (user or kernel) */ | ||
38 | #define IAS_KERNEL_ATTR 0 | ||
39 | #define IAS_USER_ATTR 1 | ||
40 | |||
41 | /* | ||
42 | * LM-IAS Object | ||
43 | */ | ||
44 | struct ias_object { | ||
45 | irda_queue_t q; /* Must be first! */ | ||
46 | magic_t magic; | ||
47 | |||
48 | char *name; | ||
49 | int id; | ||
50 | hashbin_t *attribs; | ||
51 | }; | ||
52 | |||
53 | /* | ||
54 | * Values used by LM-IAS attributes | ||
55 | */ | ||
56 | struct ias_value { | ||
57 | __u8 type; /* Value description */ | ||
58 | __u8 owner; /* Managed from user/kernel space */ | ||
59 | int charset; /* Only used by string type */ | ||
60 | int len; | ||
61 | |||
62 | /* Value */ | ||
63 | union { | ||
64 | int integer; | ||
65 | char *string; | ||
66 | __u8 *oct_seq; | ||
67 | } t; | ||
68 | }; | ||
69 | |||
70 | /* | ||
71 | * Attributes used by LM-IAS objects | ||
72 | */ | ||
73 | struct ias_attrib { | ||
74 | irda_queue_t q; /* Must be first! */ | ||
75 | int magic; | ||
76 | |||
77 | char *name; /* Attribute name */ | ||
78 | struct ias_value *value; /* Attribute value */ | ||
79 | }; | ||
80 | |||
81 | struct ias_object *irias_new_object(char *name, int id); | ||
82 | void irias_insert_object(struct ias_object *obj); | ||
83 | int irias_delete_object(struct ias_object *obj); | ||
84 | int irias_delete_attrib(struct ias_object *obj, struct ias_attrib *attrib, | ||
85 | int cleanobject); | ||
86 | void __irias_delete_object(struct ias_object *obj); | ||
87 | |||
88 | void irias_add_integer_attrib(struct ias_object *obj, char *name, int value, | ||
89 | int user); | ||
90 | void irias_add_string_attrib(struct ias_object *obj, char *name, char *value, | ||
91 | int user); | ||
92 | void irias_add_octseq_attrib(struct ias_object *obj, char *name, __u8 *octets, | ||
93 | int len, int user); | ||
94 | int irias_object_change_attribute(char *obj_name, char *attrib_name, | ||
95 | struct ias_value *new_value); | ||
96 | struct ias_object *irias_find_object(char *name); | ||
97 | struct ias_attrib *irias_find_attrib(struct ias_object *obj, char *name); | ||
98 | |||
99 | struct ias_value *irias_new_string_value(char *string); | ||
100 | struct ias_value *irias_new_integer_value(int integer); | ||
101 | struct ias_value *irias_new_octseq_value(__u8 *octseq , int len); | ||
102 | struct ias_value *irias_new_missing_value(void); | ||
103 | void irias_delete_value(struct ias_value *value); | ||
104 | |||
105 | extern struct ias_value irias_missing; | ||
106 | extern hashbin_t *irias_objects; | ||
107 | |||
108 | #endif | ||
diff --git a/include/net/irda/irlan_client.h b/include/net/irda/irlan_client.h new file mode 100644 index 000000000000..736dabe211e3 --- /dev/null +++ b/include/net/irda/irlan_client.h | |||
@@ -0,0 +1,42 @@ | |||
1 | /********************************************************************* | ||
2 | * | ||
3 | * Filename: irlan_client.h | ||
4 | * Version: 0.3 | ||
5 | * Description: IrDA LAN access layer | ||
6 | * Status: Experimental. | ||
7 | * Author: Dag Brattli <dagb@cs.uit.no> | ||
8 | * Created at: Sun Aug 31 20:14:37 1997 | ||
9 | * Modified at: Thu Apr 22 14:13:34 1999 | ||
10 | * Modified by: Dag Brattli <dagb@cs.uit.no> | ||
11 | * | ||
12 | * Copyright (c) 1998 Dag Brattli <dagb@cs.uit.no>, All Rights Reserved. | ||
13 | * | ||
14 | * This program is free software; you can redistribute it and/or | ||
15 | * modify it under the terms of the GNU General Public License as | ||
16 | * published by the Free Software Foundation; either version 2 of | ||
17 | * the License, or (at your option) any later version. | ||
18 | * | ||
19 | * Neither Dag Brattli nor University of Tromsų admit liability nor | ||
20 | * provide warranty for any of this software. This material is | ||
21 | * provided "AS-IS" and at no charge. | ||
22 | * | ||
23 | ********************************************************************/ | ||
24 | |||
25 | #ifndef IRLAN_CLIENT_H | ||
26 | #define IRLAN_CLIENT_H | ||
27 | |||
28 | #include <linux/kernel.h> | ||
29 | #include <linux/types.h> | ||
30 | #include <linux/skbuff.h> | ||
31 | #include <linux/netdevice.h> | ||
32 | |||
33 | #include <net/irda/irias_object.h> | ||
34 | #include <net/irda/irlan_event.h> | ||
35 | |||
36 | void irlan_client_discovery_indication(discinfo_t *, DISCOVERY_MODE, void *); | ||
37 | void irlan_client_wakeup(struct irlan_cb *self, __u32 saddr, __u32 daddr); | ||
38 | |||
39 | void irlan_client_parse_response(struct irlan_cb *self, struct sk_buff *skb); | ||
40 | void irlan_client_get_value_confirm(int result, __u16 obj_id, | ||
41 | struct ias_value *value, void *priv); | ||
42 | #endif | ||
diff --git a/include/net/irda/irlan_common.h b/include/net/irda/irlan_common.h new file mode 100644 index 000000000000..1c73bdbc3eb3 --- /dev/null +++ b/include/net/irda/irlan_common.h | |||
@@ -0,0 +1,222 @@ | |||
1 | /********************************************************************* | ||
2 | * | ||
3 | * Filename: irlan_common.h | ||
4 | * Version: 0.8 | ||
5 | * Description: IrDA LAN access layer | ||
6 | * Status: Experimental. | ||
7 | * Author: Dag Brattli <dagb@cs.uit.no> | ||
8 | * Created at: Sun Aug 31 20:14:37 1997 | ||
9 | * Modified at: Sun Oct 31 19:41:24 1999 | ||
10 | * Modified by: Dag Brattli <dagb@cs.uit.no> | ||
11 | * | ||
12 | * Copyright (c) 1998-1999 Dag Brattli <dagb@cs.uit.no>, | ||
13 | * All Rights Reserved. | ||
14 | * | ||
15 | * This program is free software; you can redistribute it and/or | ||
16 | * modify it under the terms of the GNU General Public License as | ||
17 | * published by the Free Software Foundation; either version 2 of | ||
18 | * the License, or (at your option) any later version. | ||
19 | * | ||
20 | * Neither Dag Brattli nor University of Tromsų admit liability nor | ||
21 | * provide warranty for any of this software. This material is | ||
22 | * provided "AS-IS" and at no charge. | ||
23 | * | ||
24 | ********************************************************************/ | ||
25 | |||
26 | #ifndef IRLAN_H | ||
27 | #define IRLAN_H | ||
28 | |||
29 | #include <asm/param.h> /* for HZ */ | ||
30 | |||
31 | #include <linux/kernel.h> | ||
32 | #include <linux/types.h> | ||
33 | #include <linux/skbuff.h> | ||
34 | #include <linux/netdevice.h> | ||
35 | |||
36 | #include <net/irda/irttp.h> | ||
37 | |||
38 | #define IRLAN_MTU 1518 | ||
39 | #define IRLAN_TIMEOUT 10*HZ /* 10 seconds */ | ||
40 | |||
41 | /* Command packet types */ | ||
42 | #define CMD_GET_PROVIDER_INFO 0 | ||
43 | #define CMD_GET_MEDIA_CHAR 1 | ||
44 | #define CMD_OPEN_DATA_CHANNEL 2 | ||
45 | #define CMD_CLOSE_DATA_CHAN 3 | ||
46 | #define CMD_RECONNECT_DATA_CHAN 4 | ||
47 | #define CMD_FILTER_OPERATION 5 | ||
48 | |||
49 | /* Some responses */ | ||
50 | #define RSP_SUCCESS 0 | ||
51 | #define RSP_INSUFFICIENT_RESOURCES 1 | ||
52 | #define RSP_INVALID_COMMAND_FORMAT 2 | ||
53 | #define RSP_COMMAND_NOT_SUPPORTED 3 | ||
54 | #define RSP_PARAM_NOT_SUPPORTED 4 | ||
55 | #define RSP_VALUE_NOT_SUPPORTED 5 | ||
56 | #define RSP_NOT_OPEN 6 | ||
57 | #define RSP_AUTHENTICATION_REQUIRED 7 | ||
58 | #define RSP_INVALID_PASSWORD 8 | ||
59 | #define RSP_PROTOCOL_ERROR 9 | ||
60 | #define RSP_ASYNCHRONOUS_ERROR 255 | ||
61 | |||
62 | /* Media types */ | ||
63 | #define MEDIA_802_3 1 | ||
64 | #define MEDIA_802_5 2 | ||
65 | |||
66 | /* Filter parameters */ | ||
67 | #define DATA_CHAN 1 | ||
68 | #define FILTER_TYPE 2 | ||
69 | #define FILTER_MODE 3 | ||
70 | |||
71 | /* Filter types */ | ||
72 | #define IRLAN_DIRECTED 0x01 | ||
73 | #define IRLAN_FUNCTIONAL 0x02 | ||
74 | #define IRLAN_GROUP 0x04 | ||
75 | #define IRLAN_MAC_FRAME 0x08 | ||
76 | #define IRLAN_MULTICAST 0x10 | ||
77 | #define IRLAN_BROADCAST 0x20 | ||
78 | #define IRLAN_IPX_SOCKET 0x40 | ||
79 | |||
80 | /* Filter modes */ | ||
81 | #define ALL 1 | ||
82 | #define FILTER 2 | ||
83 | #define NONE 3 | ||
84 | |||
85 | /* Filter operations */ | ||
86 | #define GET 1 | ||
87 | #define CLEAR 2 | ||
88 | #define ADD 3 | ||
89 | #define REMOVE 4 | ||
90 | #define DYNAMIC 5 | ||
91 | |||
92 | /* Access types */ | ||
93 | #define ACCESS_DIRECT 1 | ||
94 | #define ACCESS_PEER 2 | ||
95 | #define ACCESS_HOSTED 3 | ||
96 | |||
97 | #define IRLAN_BYTE 0 | ||
98 | #define IRLAN_SHORT 1 | ||
99 | #define IRLAN_ARRAY 2 | ||
100 | |||
101 | #define IRLAN_MAX_HEADER (TTP_HEADER+LMP_HEADER+LAP_MAX_HEADER) | ||
102 | |||
103 | /* | ||
104 | * IrLAN client | ||
105 | */ | ||
106 | struct irlan_client_cb { | ||
107 | int state; | ||
108 | |||
109 | int open_retries; | ||
110 | |||
111 | struct tsap_cb *tsap_ctrl; | ||
112 | __u32 max_sdu_size; | ||
113 | __u8 max_header_size; | ||
114 | |||
115 | int access_type; /* Access type of provider */ | ||
116 | __u8 reconnect_key[255]; | ||
117 | __u8 key_len; | ||
118 | |||
119 | __u16 recv_arb_val; | ||
120 | __u16 max_frame; | ||
121 | int filter_type; | ||
122 | |||
123 | int unicast_open; | ||
124 | int broadcast_open; | ||
125 | |||
126 | int tx_busy; | ||
127 | struct sk_buff_head txq; /* Transmit control queue */ | ||
128 | |||
129 | struct iriap_cb *iriap; | ||
130 | |||
131 | struct timer_list kick_timer; | ||
132 | }; | ||
133 | |||
134 | /* | ||
135 | * IrLAN provider | ||
136 | */ | ||
137 | struct irlan_provider_cb { | ||
138 | int state; | ||
139 | |||
140 | struct tsap_cb *tsap_ctrl; | ||
141 | __u32 max_sdu_size; | ||
142 | __u8 max_header_size; | ||
143 | |||
144 | /* | ||
145 | * Store some values here which are used by the provider to parse | ||
146 | * the filter operations | ||
147 | */ | ||
148 | int data_chan; | ||
149 | int filter_type; | ||
150 | int filter_mode; | ||
151 | int filter_operation; | ||
152 | int filter_entry; | ||
153 | int access_type; /* Access type */ | ||
154 | __u16 send_arb_val; | ||
155 | |||
156 | __u8 mac_address[6]; /* Generated MAC address for peer device */ | ||
157 | }; | ||
158 | |||
159 | /* | ||
160 | * IrLAN control block | ||
161 | */ | ||
162 | struct irlan_cb { | ||
163 | int magic; | ||
164 | struct list_head dev_list; | ||
165 | struct net_device *dev; /* Ethernet device structure*/ | ||
166 | struct net_device_stats stats; | ||
167 | |||
168 | __u32 saddr; /* Source device address */ | ||
169 | __u32 daddr; /* Destination device address */ | ||
170 | int disconnect_reason; /* Why we got disconnected */ | ||
171 | |||
172 | int media; /* Media type */ | ||
173 | __u8 version[2]; /* IrLAN version */ | ||
174 | |||
175 | struct tsap_cb *tsap_data; /* Data TSAP */ | ||
176 | |||
177 | int use_udata; /* Use Unit Data transfers */ | ||
178 | |||
179 | __u8 stsap_sel_data; /* Source data TSAP selector */ | ||
180 | __u8 dtsap_sel_data; /* Destination data TSAP selector */ | ||
181 | __u8 dtsap_sel_ctrl; /* Destination ctrl TSAP selector */ | ||
182 | |||
183 | struct irlan_client_cb client; /* Client specific fields */ | ||
184 | struct irlan_provider_cb provider; /* Provider specific fields */ | ||
185 | |||
186 | __u32 max_sdu_size; | ||
187 | __u8 max_header_size; | ||
188 | |||
189 | wait_queue_head_t open_wait; | ||
190 | struct timer_list watchdog_timer; | ||
191 | }; | ||
192 | |||
193 | void irlan_close(struct irlan_cb *self); | ||
194 | void irlan_close_tsaps(struct irlan_cb *self); | ||
195 | |||
196 | int irlan_register_netdev(struct irlan_cb *self); | ||
197 | void irlan_ias_register(struct irlan_cb *self, __u8 tsap_sel); | ||
198 | void irlan_start_watchdog_timer(struct irlan_cb *self, int timeout); | ||
199 | |||
200 | void irlan_open_data_tsap(struct irlan_cb *self); | ||
201 | |||
202 | int irlan_run_ctrl_tx_queue(struct irlan_cb *self); | ||
203 | |||
204 | struct irlan_cb *irlan_get_any(void); | ||
205 | void irlan_get_provider_info(struct irlan_cb *self); | ||
206 | void irlan_get_media_char(struct irlan_cb *self); | ||
207 | void irlan_open_data_channel(struct irlan_cb *self); | ||
208 | void irlan_close_data_channel(struct irlan_cb *self); | ||
209 | void irlan_set_multicast_filter(struct irlan_cb *self, int status); | ||
210 | void irlan_set_broadcast_filter(struct irlan_cb *self, int status); | ||
211 | |||
212 | int irlan_insert_byte_param(struct sk_buff *skb, char *param, __u8 value); | ||
213 | int irlan_insert_short_param(struct sk_buff *skb, char *param, __u16 value); | ||
214 | int irlan_insert_string_param(struct sk_buff *skb, char *param, char *value); | ||
215 | int irlan_insert_array_param(struct sk_buff *skb, char *name, __u8 *value, | ||
216 | __u16 value_len); | ||
217 | |||
218 | int irlan_extract_param(__u8 *buf, char *name, char *value, __u16 *len); | ||
219 | |||
220 | #endif | ||
221 | |||
222 | |||
diff --git a/include/net/irda/irlan_eth.h b/include/net/irda/irlan_eth.h new file mode 100644 index 000000000000..9a9b3619d305 --- /dev/null +++ b/include/net/irda/irlan_eth.h | |||
@@ -0,0 +1,33 @@ | |||
1 | /********************************************************************* | ||
2 | * | ||
3 | * Filename: irlan_eth.h | ||
4 | * Version: | ||
5 | * Description: | ||
6 | * Status: Experimental. | ||
7 | * Author: Dag Brattli <dagb@cs.uit.no> | ||
8 | * Created at: Thu Oct 15 08:36:58 1998 | ||
9 | * Modified at: Fri May 14 23:29:00 1999 | ||
10 | * Modified by: Dag Brattli <dagb@cs.uit.no> | ||
11 | * | ||
12 | * Copyright (c) 1998-1999 Dag Brattli, All Rights Reserved. | ||
13 | * | ||
14 | * This program is free software; you can redistribute it and/or | ||
15 | * modify it under the terms of the GNU General Public License as | ||
16 | * published by the Free Software Foundation; either version 2 of | ||
17 | * the License, or (at your option) any later version. | ||
18 | * | ||
19 | * Neither Dag Brattli nor University of Tromsų admit liability nor | ||
20 | * provide warranty for any of this software. This material is | ||
21 | * provided "AS-IS" and at no charge. | ||
22 | * | ||
23 | ********************************************************************/ | ||
24 | |||
25 | #ifndef IRLAN_ETH_H | ||
26 | #define IRLAN_ETH_H | ||
27 | |||
28 | struct net_device *alloc_irlandev(const char *name); | ||
29 | int irlan_eth_receive(void *instance, void *sap, struct sk_buff *skb); | ||
30 | |||
31 | void irlan_eth_flow_indication( void *instance, void *sap, LOCAL_FLOW flow); | ||
32 | void irlan_eth_send_gratuitous_arp(struct net_device *dev); | ||
33 | #endif | ||
diff --git a/include/net/irda/irlan_event.h b/include/net/irda/irlan_event.h new file mode 100644 index 000000000000..b9baac9eb8b6 --- /dev/null +++ b/include/net/irda/irlan_event.h | |||
@@ -0,0 +1,81 @@ | |||
1 | /********************************************************************* | ||
2 | * | ||
3 | * Filename: irlan_event.h | ||
4 | * Version: | ||
5 | * Description: LAN access | ||
6 | * Status: Experimental. | ||
7 | * Author: Dag Brattli <dagb@cs.uit.no> | ||
8 | * Created at: Sun Aug 31 20:14:37 1997 | ||
9 | * Modified at: Tue Feb 2 09:45:17 1999 | ||
10 | * Modified by: Dag Brattli <dagb@cs.uit.no> | ||
11 | * | ||
12 | * Copyright (c) 1997 Dag Brattli <dagb@cs.uit.no>, All Rights Reserved. | ||
13 | * | ||
14 | * This program is free software; you can redistribute it and/or | ||
15 | * modify it under the terms of the GNU General Public License as | ||
16 | * published by the Free Software Foundation; either version 2 of | ||
17 | * the License, or (at your option) any later version. | ||
18 | * | ||
19 | * Neither Dag Brattli nor University of Tromsų admit liability nor | ||
20 | * provide warranty for any of this software. This material is | ||
21 | * provided "AS-IS" and at no charge. | ||
22 | * | ||
23 | ********************************************************************/ | ||
24 | |||
25 | #ifndef IRLAN_EVENT_H | ||
26 | #define IRLAN_EVENT_H | ||
27 | |||
28 | #include <linux/kernel.h> | ||
29 | #include <linux/skbuff.h> | ||
30 | |||
31 | #include <net/irda/irlan_common.h> | ||
32 | |||
33 | typedef enum { | ||
34 | IRLAN_IDLE, | ||
35 | IRLAN_QUERY, | ||
36 | IRLAN_CONN, | ||
37 | IRLAN_INFO, | ||
38 | IRLAN_MEDIA, | ||
39 | IRLAN_OPEN, | ||
40 | IRLAN_WAIT, | ||
41 | IRLAN_ARB, | ||
42 | IRLAN_DATA, | ||
43 | IRLAN_CLOSE, | ||
44 | IRLAN_SYNC | ||
45 | } IRLAN_STATE; | ||
46 | |||
47 | typedef enum { | ||
48 | IRLAN_DISCOVERY_INDICATION, | ||
49 | IRLAN_IAS_PROVIDER_AVAIL, | ||
50 | IRLAN_IAS_PROVIDER_NOT_AVAIL, | ||
51 | IRLAN_LAP_DISCONNECT, | ||
52 | IRLAN_LMP_DISCONNECT, | ||
53 | IRLAN_CONNECT_COMPLETE, | ||
54 | IRLAN_DATA_INDICATION, | ||
55 | IRLAN_DATA_CONNECT_INDICATION, | ||
56 | IRLAN_RETRY_CONNECT, | ||
57 | |||
58 | IRLAN_CONNECT_INDICATION, | ||
59 | IRLAN_GET_INFO_CMD, | ||
60 | IRLAN_GET_MEDIA_CMD, | ||
61 | IRLAN_OPEN_DATA_CMD, | ||
62 | IRLAN_FILTER_CONFIG_CMD, | ||
63 | |||
64 | IRLAN_CHECK_CON_ARB, | ||
65 | IRLAN_PROVIDER_SIGNAL, | ||
66 | |||
67 | IRLAN_WATCHDOG_TIMEOUT, | ||
68 | } IRLAN_EVENT; | ||
69 | |||
70 | extern char *irlan_state[]; | ||
71 | |||
72 | void irlan_do_client_event(struct irlan_cb *self, IRLAN_EVENT event, | ||
73 | struct sk_buff *skb); | ||
74 | |||
75 | void irlan_do_provider_event(struct irlan_cb *self, IRLAN_EVENT event, | ||
76 | struct sk_buff *skb); | ||
77 | |||
78 | void irlan_next_client_state(struct irlan_cb *self, IRLAN_STATE state); | ||
79 | void irlan_next_provider_state(struct irlan_cb *self, IRLAN_STATE state); | ||
80 | |||
81 | #endif | ||
diff --git a/include/net/irda/irlan_filter.h b/include/net/irda/irlan_filter.h new file mode 100644 index 000000000000..3afeb6c94ea4 --- /dev/null +++ b/include/net/irda/irlan_filter.h | |||
@@ -0,0 +1,33 @@ | |||
1 | /********************************************************************* | ||
2 | * | ||
3 | * Filename: irlan_filter.h | ||
4 | * Version: | ||
5 | * Description: | ||
6 | * Status: Experimental. | ||
7 | * Author: Dag Brattli <dagb@cs.uit.no> | ||
8 | * Created at: Fri Jan 29 15:24:08 1999 | ||
9 | * Modified at: Sun Feb 7 23:35:31 1999 | ||
10 | * Modified by: Dag Brattli <dagb@cs.uit.no> | ||
11 | * | ||
12 | * Copyright (c) 1998 Dag Brattli, All Rights Reserved. | ||
13 | * | ||
14 | * This program is free software; you can redistribute it and/or | ||
15 | * modify it under the terms of the GNU General Public License as | ||
16 | * published by the Free Software Foundation; either version 2 of | ||
17 | * the License, or (at your option) any later version. | ||
18 | * | ||
19 | * Neither Dag Brattli nor University of Tromsų admit liability nor | ||
20 | * provide warranty for any of this software. This material is | ||
21 | * provided "AS-IS" and at no charge. | ||
22 | * | ||
23 | ********************************************************************/ | ||
24 | |||
25 | #ifndef IRLAN_FILTER_H | ||
26 | #define IRLAN_FILTER_H | ||
27 | |||
28 | void irlan_check_command_param(struct irlan_cb *self, char *param, | ||
29 | char *value); | ||
30 | void irlan_filter_request(struct irlan_cb *self, struct sk_buff *skb); | ||
31 | int irlan_print_filter(struct seq_file *seq, int filter_type); | ||
32 | |||
33 | #endif /* IRLAN_FILTER_H */ | ||
diff --git a/include/net/irda/irlan_provider.h b/include/net/irda/irlan_provider.h new file mode 100644 index 000000000000..ca51d5b7c999 --- /dev/null +++ b/include/net/irda/irlan_provider.h | |||
@@ -0,0 +1,52 @@ | |||
1 | /********************************************************************* | ||
2 | * | ||
3 | * Filename: irlan_provider.h | ||
4 | * Version: 0.1 | ||
5 | * Description: IrDA LAN access layer | ||
6 | * Status: Experimental. | ||
7 | * Author: Dag Brattli <dagb@cs.uit.no> | ||
8 | * Created at: Sun Aug 31 20:14:37 1997 | ||
9 | * Modified at: Sun May 9 12:26:11 1999 | ||
10 | * Modified by: Dag Brattli <dagb@cs.uit.no> | ||
11 | * | ||
12 | * Copyright (c) 1998-1999 Dag Brattli <dagb@cs.uit.no>, All Rights Reserved. | ||
13 | * | ||
14 | * This program is free software; you can redistribute it and/or | ||
15 | * modify it under the terms of the GNU General Public License as | ||
16 | * published by the Free Software Foundation; either version 2 of | ||
17 | * the License, or (at your option) any later version. | ||
18 | * | ||
19 | * Neither Dag Brattli nor University of Tromsų admit liability nor | ||
20 | * provide warranty for any of this software. This material is | ||
21 | * provided "AS-IS" and at no charge. | ||
22 | * | ||
23 | ********************************************************************/ | ||
24 | |||
25 | #ifndef IRLAN_SERVER_H | ||
26 | #define IRLAN_SERVER_H | ||
27 | |||
28 | #include <linux/kernel.h> | ||
29 | #include <linux/types.h> | ||
30 | #include <linux/skbuff.h> | ||
31 | #include <linux/netdevice.h> | ||
32 | |||
33 | #include <net/irda/irlan_common.h> | ||
34 | |||
35 | void irlan_provider_ctrl_disconnect_indication(void *instance, void *sap, | ||
36 | LM_REASON reason, | ||
37 | struct sk_buff *skb); | ||
38 | |||
39 | |||
40 | void irlan_provider_connect_response(struct irlan_cb *, struct tsap_cb *); | ||
41 | |||
42 | int irlan_parse_open_data_cmd(struct irlan_cb *self, struct sk_buff *skb); | ||
43 | int irlan_provider_parse_command(struct irlan_cb *self, int cmd, | ||
44 | struct sk_buff *skb); | ||
45 | |||
46 | void irlan_provider_send_reply(struct irlan_cb *self, int command, | ||
47 | int ret_code); | ||
48 | int irlan_provider_open_ctrl_tsap(struct irlan_cb *self); | ||
49 | |||
50 | #endif | ||
51 | |||
52 | |||
diff --git a/include/net/irda/irlap.h b/include/net/irda/irlap.h new file mode 100644 index 000000000000..f55e86e75030 --- /dev/null +++ b/include/net/irda/irlap.h | |||
@@ -0,0 +1,290 @@ | |||
1 | /********************************************************************* | ||
2 | * | ||
3 | * Filename: irlap.h | ||
4 | * Version: 0.8 | ||
5 | * Description: An IrDA LAP driver for Linux | ||
6 | * Status: Experimental. | ||
7 | * Author: Dag Brattli <dagb@cs.uit.no> | ||
8 | * Created at: Mon Aug 4 20:40:53 1997 | ||
9 | * Modified at: Fri Dec 10 13:21:17 1999 | ||
10 | * Modified by: Dag Brattli <dagb@cs.uit.no> | ||
11 | * | ||
12 | * Copyright (c) 1998-1999 Dag Brattli <dagb@cs.uit.no>, | ||
13 | * All Rights Reserved. | ||
14 | * Copyright (c) 2000-2002 Jean Tourrilhes <jt@hpl.hp.com> | ||
15 | * | ||
16 | * This program is free software; you can redistribute it and/or | ||
17 | * modify it under the terms of the GNU General Public License as | ||
18 | * published by the Free Software Foundation; either version 2 of | ||
19 | * the License, or (at your option) any later version. | ||
20 | * | ||
21 | * Neither Dag Brattli nor University of Tromsų admit liability nor | ||
22 | * provide warranty for any of this software. This material is | ||
23 | * provided "AS-IS" and at no charge. | ||
24 | * | ||
25 | ********************************************************************/ | ||
26 | |||
27 | #ifndef IRLAP_H | ||
28 | #define IRLAP_H | ||
29 | |||
30 | #include <linux/config.h> | ||
31 | #include <linux/types.h> | ||
32 | #include <linux/skbuff.h> | ||
33 | #include <linux/netdevice.h> | ||
34 | #include <linux/timer.h> | ||
35 | |||
36 | #include <net/irda/irqueue.h> /* irda_queue_t */ | ||
37 | #include <net/irda/qos.h> /* struct qos_info */ | ||
38 | #include <net/irda/discovery.h> /* discovery_t */ | ||
39 | #include <net/irda/irlap_event.h> /* IRLAP_STATE, ... */ | ||
40 | #include <net/irda/irmod.h> /* struct notify_t */ | ||
41 | |||
42 | #define CONFIG_IRDA_DYNAMIC_WINDOW 1 | ||
43 | |||
44 | #define LAP_RELIABLE 1 | ||
45 | #define LAP_UNRELIABLE 0 | ||
46 | |||
47 | #define LAP_ADDR_HEADER 1 /* IrLAP Address Header */ | ||
48 | #define LAP_CTRL_HEADER 1 /* IrLAP Control Header */ | ||
49 | |||
50 | /* May be different when we get VFIR */ | ||
51 | #define LAP_MAX_HEADER (LAP_ADDR_HEADER + LAP_CTRL_HEADER) | ||
52 | |||
53 | #define BROADCAST 0xffffffff /* Broadcast device address */ | ||
54 | #define CBROADCAST 0xfe /* Connection broadcast address */ | ||
55 | #define XID_FORMAT 0x01 /* Discovery XID format */ | ||
56 | |||
57 | /* Nobody seems to use this constant. */ | ||
58 | #define LAP_WINDOW_SIZE 8 | ||
59 | /* We keep the LAP queue very small to minimise the amount of buffering. | ||
60 | * this improve latency and reduce resource consumption. | ||
61 | * This work only because we have synchronous refilling of IrLAP through | ||
62 | * the flow control mechanism (via scheduler and IrTTP). | ||
63 | * 2 buffers is the minimum we can work with, one that we send while polling | ||
64 | * IrTTP, and another to know that we should not send the pf bit. | ||
65 | * Jean II */ | ||
66 | #define LAP_HIGH_THRESHOLD 2 | ||
67 | /* Some rare non TTP clients don't implement flow control, and | ||
68 | * so don't comply with the above limit (and neither with this one). | ||
69 | * For IAP and management, it doesn't matter, because they never transmit much. | ||
70 | *.For IrLPT, this should be fixed. | ||
71 | * - Jean II */ | ||
72 | #define LAP_MAX_QUEUE 10 | ||
73 | /* Please note that all IrDA management frames (LMP/TTP conn req/disc and | ||
74 | * IAS queries) fall in the second category and are sent to LAP even if TTP | ||
75 | * is stopped. This means that those frames will wait only a maximum of | ||
76 | * two (2) data frames before beeing sent on the "wire", which speed up | ||
77 | * new socket setup when the link is saturated. | ||
78 | * Same story for two sockets competing for the medium : if one saturates | ||
79 | * the LAP, when the other want to transmit it only has to wait for | ||
80 | * maximum three (3) packets (2 + one scheduling), which improve performance | ||
81 | * of delay sensitive applications. | ||
82 | * Jean II */ | ||
83 | |||
84 | #define NR_EXPECTED 1 | ||
85 | #define NR_UNEXPECTED 0 | ||
86 | #define NR_INVALID -1 | ||
87 | |||
88 | #define NS_EXPECTED 1 | ||
89 | #define NS_UNEXPECTED 0 | ||
90 | #define NS_INVALID -1 | ||
91 | |||
92 | /* | ||
93 | * Meta information passed within the IrLAP state machine | ||
94 | */ | ||
95 | struct irlap_info { | ||
96 | __u8 caddr; /* Connection address */ | ||
97 | __u8 control; /* Frame type */ | ||
98 | __u8 cmd; | ||
99 | |||
100 | __u32 saddr; | ||
101 | __u32 daddr; | ||
102 | |||
103 | int pf; /* Poll/final bit set */ | ||
104 | |||
105 | __u8 nr; /* Sequence number of next frame expected */ | ||
106 | __u8 ns; /* Sequence number of frame sent */ | ||
107 | |||
108 | int S; /* Number of slots */ | ||
109 | int slot; /* Random chosen slot */ | ||
110 | int s; /* Current slot */ | ||
111 | |||
112 | discovery_t *discovery; /* Discovery information */ | ||
113 | }; | ||
114 | |||
115 | /* Main structure of IrLAP */ | ||
116 | struct irlap_cb { | ||
117 | irda_queue_t q; /* Must be first */ | ||
118 | magic_t magic; | ||
119 | |||
120 | /* Device we are attached to */ | ||
121 | struct net_device *netdev; | ||
122 | char hw_name[2*IFNAMSIZ + 1]; | ||
123 | |||
124 | /* Connection state */ | ||
125 | volatile IRLAP_STATE state; /* Current state */ | ||
126 | |||
127 | /* Timers used by IrLAP */ | ||
128 | struct timer_list query_timer; | ||
129 | struct timer_list slot_timer; | ||
130 | struct timer_list discovery_timer; | ||
131 | struct timer_list final_timer; | ||
132 | struct timer_list poll_timer; | ||
133 | struct timer_list wd_timer; | ||
134 | struct timer_list backoff_timer; | ||
135 | |||
136 | /* Media busy stuff */ | ||
137 | struct timer_list media_busy_timer; | ||
138 | int media_busy; | ||
139 | |||
140 | /* Timeouts which will be different with different turn time */ | ||
141 | int slot_timeout; | ||
142 | int poll_timeout; | ||
143 | int final_timeout; | ||
144 | int wd_timeout; | ||
145 | |||
146 | struct sk_buff_head txq; /* Frames to be transmitted */ | ||
147 | struct sk_buff_head txq_ultra; | ||
148 | |||
149 | __u8 caddr; /* Connection address */ | ||
150 | __u32 saddr; /* Source device address */ | ||
151 | __u32 daddr; /* Destination device address */ | ||
152 | |||
153 | int retry_count; /* Times tried to establish connection */ | ||
154 | int add_wait; /* True if we are waiting for frame */ | ||
155 | |||
156 | __u8 connect_pending; | ||
157 | __u8 disconnect_pending; | ||
158 | |||
159 | /* To send a faster RR if tx queue empty */ | ||
160 | #ifdef CONFIG_IRDA_FAST_RR | ||
161 | int fast_RR_timeout; | ||
162 | int fast_RR; | ||
163 | #endif /* CONFIG_IRDA_FAST_RR */ | ||
164 | |||
165 | int N1; /* N1 * F-timer = Negitiated link disconnect warning threshold */ | ||
166 | int N2; /* N2 * F-timer = Negitiated link disconnect time */ | ||
167 | int N3; /* Connection retry count */ | ||
168 | |||
169 | int local_busy; | ||
170 | int remote_busy; | ||
171 | int xmitflag; | ||
172 | |||
173 | __u8 vs; /* Next frame to be sent */ | ||
174 | __u8 vr; /* Next frame to be received */ | ||
175 | __u8 va; /* Last frame acked */ | ||
176 | int window; /* Nr of I-frames allowed to send */ | ||
177 | int window_size; /* Current negotiated window size */ | ||
178 | |||
179 | #ifdef CONFIG_IRDA_DYNAMIC_WINDOW | ||
180 | __u32 line_capacity; /* Number of bytes allowed to send */ | ||
181 | __u32 bytes_left; /* Number of bytes still allowed to transmit */ | ||
182 | #endif /* CONFIG_IRDA_DYNAMIC_WINDOW */ | ||
183 | |||
184 | struct sk_buff_head wx_list; | ||
185 | |||
186 | __u8 ack_required; | ||
187 | |||
188 | /* XID parameters */ | ||
189 | __u8 S; /* Number of slots */ | ||
190 | __u8 slot; /* Random chosen slot */ | ||
191 | __u8 s; /* Current slot */ | ||
192 | int frame_sent; /* Have we sent reply? */ | ||
193 | |||
194 | hashbin_t *discovery_log; | ||
195 | discovery_t *discovery_cmd; | ||
196 | |||
197 | __u32 speed; /* Link speed */ | ||
198 | |||
199 | struct qos_info qos_tx; /* QoS requested by peer */ | ||
200 | struct qos_info qos_rx; /* QoS requested by self */ | ||
201 | struct qos_info *qos_dev; /* QoS supported by device */ | ||
202 | |||
203 | notify_t notify; /* Callbacks to IrLMP */ | ||
204 | |||
205 | int mtt_required; /* Minumum turnaround time required */ | ||
206 | int xbofs_delay; /* Nr of XBOF's used to MTT */ | ||
207 | int bofs_count; /* Negotiated extra BOFs */ | ||
208 | int next_bofs; /* Negotiated extra BOFs after next frame */ | ||
209 | }; | ||
210 | |||
211 | /* | ||
212 | * Function prototypes | ||
213 | */ | ||
214 | int irlap_init(void); | ||
215 | void irlap_cleanup(void); | ||
216 | |||
217 | struct irlap_cb *irlap_open(struct net_device *dev, struct qos_info *qos, | ||
218 | const char *hw_name); | ||
219 | void irlap_close(struct irlap_cb *self); | ||
220 | |||
221 | void irlap_connect_request(struct irlap_cb *self, __u32 daddr, | ||
222 | struct qos_info *qos, int sniff); | ||
223 | void irlap_connect_response(struct irlap_cb *self, struct sk_buff *skb); | ||
224 | void irlap_connect_indication(struct irlap_cb *self, struct sk_buff *skb); | ||
225 | void irlap_connect_confirm(struct irlap_cb *, struct sk_buff *skb); | ||
226 | |||
227 | void irlap_data_indication(struct irlap_cb *, struct sk_buff *, int unreliable); | ||
228 | void irlap_data_request(struct irlap_cb *, struct sk_buff *, int unreliable); | ||
229 | |||
230 | #ifdef CONFIG_IRDA_ULTRA | ||
231 | void irlap_unitdata_request(struct irlap_cb *, struct sk_buff *); | ||
232 | void irlap_unitdata_indication(struct irlap_cb *, struct sk_buff *); | ||
233 | #endif /* CONFIG_IRDA_ULTRA */ | ||
234 | |||
235 | void irlap_disconnect_request(struct irlap_cb *); | ||
236 | void irlap_disconnect_indication(struct irlap_cb *, LAP_REASON reason); | ||
237 | |||
238 | void irlap_status_indication(struct irlap_cb *, int quality_of_link); | ||
239 | |||
240 | void irlap_test_request(__u8 *info, int len); | ||
241 | |||
242 | void irlap_discovery_request(struct irlap_cb *, discovery_t *discovery); | ||
243 | void irlap_discovery_confirm(struct irlap_cb *, hashbin_t *discovery_log); | ||
244 | void irlap_discovery_indication(struct irlap_cb *, discovery_t *discovery); | ||
245 | |||
246 | void irlap_reset_indication(struct irlap_cb *self); | ||
247 | void irlap_reset_confirm(void); | ||
248 | |||
249 | void irlap_update_nr_received(struct irlap_cb *, int nr); | ||
250 | int irlap_validate_nr_received(struct irlap_cb *, int nr); | ||
251 | int irlap_validate_ns_received(struct irlap_cb *, int ns); | ||
252 | |||
253 | int irlap_generate_rand_time_slot(int S, int s); | ||
254 | void irlap_initiate_connection_state(struct irlap_cb *); | ||
255 | void irlap_flush_all_queues(struct irlap_cb *); | ||
256 | void irlap_wait_min_turn_around(struct irlap_cb *, struct qos_info *); | ||
257 | |||
258 | void irlap_apply_default_connection_parameters(struct irlap_cb *self); | ||
259 | void irlap_apply_connection_parameters(struct irlap_cb *self, int now); | ||
260 | |||
261 | #define IRLAP_GET_HEADER_SIZE(self) (LAP_MAX_HEADER) | ||
262 | #define IRLAP_GET_TX_QUEUE_LEN(self) skb_queue_len(&self->txq) | ||
263 | |||
264 | /* Return TRUE if the node is in primary mode (i.e. master) | ||
265 | * - Jean II */ | ||
266 | static inline int irlap_is_primary(struct irlap_cb *self) | ||
267 | { | ||
268 | int ret; | ||
269 | switch(self->state) { | ||
270 | case LAP_XMIT_P: | ||
271 | case LAP_NRM_P: | ||
272 | ret = 1; | ||
273 | break; | ||
274 | case LAP_XMIT_S: | ||
275 | case LAP_NRM_S: | ||
276 | ret = 0; | ||
277 | break; | ||
278 | default: | ||
279 | ret = -1; | ||
280 | } | ||
281 | return(ret); | ||
282 | } | ||
283 | |||
284 | /* Clear a pending IrLAP disconnect. - Jean II */ | ||
285 | static inline void irlap_clear_disconnect(struct irlap_cb *self) | ||
286 | { | ||
287 | self->disconnect_pending = FALSE; | ||
288 | } | ||
289 | |||
290 | #endif | ||
diff --git a/include/net/irda/irlap_event.h b/include/net/irda/irlap_event.h new file mode 100644 index 000000000000..2ae2e119ef4b --- /dev/null +++ b/include/net/irda/irlap_event.h | |||
@@ -0,0 +1,131 @@ | |||
1 | /********************************************************************* | ||
2 | * | ||
3 | * | ||
4 | * Filename: irlap_event.h | ||
5 | * Version: 0.1 | ||
6 | * Description: | ||
7 | * Status: Experimental. | ||
8 | * Author: Dag Brattli <dagb@cs.uit.no> | ||
9 | * Created at: Sat Aug 16 00:59:29 1997 | ||
10 | * Modified at: Tue Dec 21 11:20:30 1999 | ||
11 | * Modified by: Dag Brattli <dagb@cs.uit.no> | ||
12 | * | ||
13 | * Copyright (c) 1998-1999 Dag Brattli <dagb@cs.uit.no>, | ||
14 | * All Rights Reserved. | ||
15 | * Copyright (c) 2000-2002 Jean Tourrilhes <jt@hpl.hp.com> | ||
16 | * | ||
17 | * This program is free software; you can redistribute it and/or | ||
18 | * modify it under the terms of the GNU General Public License as | ||
19 | * published by the Free Software Foundation; either version 2 of | ||
20 | * the License, or (at your option) any later version. | ||
21 | * | ||
22 | * This program is distributed in the hope that it will be useful, | ||
23 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
24 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
25 | * GNU General Public License for more details. | ||
26 | * | ||
27 | * You should have received a copy of the GNU General Public License | ||
28 | * along with this program; if not, write to the Free Software | ||
29 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, | ||
30 | * MA 02111-1307 USA | ||
31 | * | ||
32 | ********************************************************************/ | ||
33 | |||
34 | #ifndef IRLAP_EVENT_H | ||
35 | #define IRLAP_EVENT_H | ||
36 | |||
37 | #include <net/irda/irda.h> | ||
38 | |||
39 | /* A few forward declarations (to make compiler happy) */ | ||
40 | struct irlap_cb; | ||
41 | struct irlap_info; | ||
42 | |||
43 | /* IrLAP States */ | ||
44 | typedef enum { | ||
45 | LAP_NDM, /* Normal disconnected mode */ | ||
46 | LAP_QUERY, | ||
47 | LAP_REPLY, | ||
48 | LAP_CONN, /* Connect indication */ | ||
49 | LAP_SETUP, /* Setting up connection */ | ||
50 | LAP_OFFLINE, /* A really boring state */ | ||
51 | LAP_XMIT_P, | ||
52 | LAP_PCLOSE, | ||
53 | LAP_NRM_P, /* Normal response mode as primary */ | ||
54 | LAP_RESET_WAIT, | ||
55 | LAP_RESET, | ||
56 | LAP_NRM_S, /* Normal response mode as secondary */ | ||
57 | LAP_XMIT_S, | ||
58 | LAP_SCLOSE, | ||
59 | LAP_RESET_CHECK, | ||
60 | } IRLAP_STATE; | ||
61 | |||
62 | /* IrLAP Events */ | ||
63 | typedef enum { | ||
64 | /* Services events */ | ||
65 | DISCOVERY_REQUEST, | ||
66 | CONNECT_REQUEST, | ||
67 | CONNECT_RESPONSE, | ||
68 | DISCONNECT_REQUEST, | ||
69 | DATA_REQUEST, | ||
70 | RESET_REQUEST, | ||
71 | RESET_RESPONSE, | ||
72 | |||
73 | /* Send events */ | ||
74 | SEND_I_CMD, | ||
75 | SEND_UI_FRAME, | ||
76 | |||
77 | /* Receive events */ | ||
78 | RECV_DISCOVERY_XID_CMD, | ||
79 | RECV_DISCOVERY_XID_RSP, | ||
80 | RECV_SNRM_CMD, | ||
81 | RECV_TEST_CMD, | ||
82 | RECV_TEST_RSP, | ||
83 | RECV_UA_RSP, | ||
84 | RECV_DM_RSP, | ||
85 | RECV_RD_RSP, | ||
86 | RECV_I_CMD, | ||
87 | RECV_I_RSP, | ||
88 | RECV_UI_FRAME, | ||
89 | RECV_FRMR_RSP, | ||
90 | RECV_RR_CMD, | ||
91 | RECV_RR_RSP, | ||
92 | RECV_RNR_CMD, | ||
93 | RECV_RNR_RSP, | ||
94 | RECV_REJ_CMD, | ||
95 | RECV_REJ_RSP, | ||
96 | RECV_SREJ_CMD, | ||
97 | RECV_SREJ_RSP, | ||
98 | RECV_DISC_CMD, | ||
99 | |||
100 | /* Timer events */ | ||
101 | SLOT_TIMER_EXPIRED, | ||
102 | QUERY_TIMER_EXPIRED, | ||
103 | FINAL_TIMER_EXPIRED, | ||
104 | POLL_TIMER_EXPIRED, | ||
105 | DISCOVERY_TIMER_EXPIRED, | ||
106 | WD_TIMER_EXPIRED, | ||
107 | BACKOFF_TIMER_EXPIRED, | ||
108 | MEDIA_BUSY_TIMER_EXPIRED, | ||
109 | } IRLAP_EVENT; | ||
110 | |||
111 | /* | ||
112 | * Disconnect reason code | ||
113 | */ | ||
114 | typedef enum { /* FIXME check the two first reason codes */ | ||
115 | LAP_DISC_INDICATION=1, /* Received a disconnect request from peer */ | ||
116 | LAP_NO_RESPONSE, /* To many retransmits without response */ | ||
117 | LAP_RESET_INDICATION, /* To many retransmits, or invalid nr/ns */ | ||
118 | LAP_FOUND_NONE, /* No devices were discovered */ | ||
119 | LAP_MEDIA_BUSY, | ||
120 | LAP_PRIMARY_CONFLICT, | ||
121 | } LAP_REASON; | ||
122 | |||
123 | extern const char *irlap_state[]; | ||
124 | |||
125 | void irlap_do_event(struct irlap_cb *self, IRLAP_EVENT event, | ||
126 | struct sk_buff *skb, struct irlap_info *info); | ||
127 | void irlap_print_event(IRLAP_EVENT event); | ||
128 | |||
129 | extern int irlap_qos_negotiate(struct irlap_cb *self, struct sk_buff *skb); | ||
130 | |||
131 | #endif | ||
diff --git a/include/net/irda/irlap_frame.h b/include/net/irda/irlap_frame.h new file mode 100644 index 000000000000..3452ae257c84 --- /dev/null +++ b/include/net/irda/irlap_frame.h | |||
@@ -0,0 +1,142 @@ | |||
1 | /********************************************************************* | ||
2 | * | ||
3 | * Filename: irlap_frame.h | ||
4 | * Version: 0.9 | ||
5 | * Description: IrLAP frame declarations | ||
6 | * Status: Experimental. | ||
7 | * Author: Dag Brattli <dagb@cs.uit.no> | ||
8 | * Created at: Tue Aug 19 10:27:26 1997 | ||
9 | * Modified at: Sat Dec 25 21:07:26 1999 | ||
10 | * Modified by: Dag Brattli <dagb@cs.uit.no> | ||
11 | * | ||
12 | * Copyright (c) 1997-1999 Dag Brattli <dagb@cs.uit.no>, | ||
13 | * All Rights Reserved. | ||
14 | * Copyright (c) 2000-2002 Jean Tourrilhes <jt@hpl.hp.com> | ||
15 | * | ||
16 | * This program is free software; you can redistribute it and/or | ||
17 | * modify it under the terms of the GNU General Public License as | ||
18 | * published by the Free Software Foundation; either version 2 of | ||
19 | * the License, or (at your option) any later version. | ||
20 | * | ||
21 | * This program is distributed in the hope that it will be useful, | ||
22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
24 | * GNU General Public License for more details. | ||
25 | * | ||
26 | * You should have received a copy of the GNU General Public License | ||
27 | * along with this program; if not, write to the Free Software | ||
28 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, | ||
29 | * MA 02111-1307 USA | ||
30 | * | ||
31 | ********************************************************************/ | ||
32 | |||
33 | #ifndef IRLAP_FRAME_H | ||
34 | #define IRLAP_FRAME_H | ||
35 | |||
36 | #include <linux/skbuff.h> | ||
37 | |||
38 | #include <net/irda/irda.h> | ||
39 | |||
40 | /* A few forward declarations (to make compiler happy) */ | ||
41 | struct irlap_cb; | ||
42 | struct discovery_t; | ||
43 | |||
44 | /* Frame types and templates */ | ||
45 | #define INVALID 0xff | ||
46 | |||
47 | /* Unnumbered (U) commands */ | ||
48 | #define SNRM_CMD 0x83 /* Set Normal Response Mode */ | ||
49 | #define DISC_CMD 0x43 /* Disconnect */ | ||
50 | #define XID_CMD 0x2f /* Exchange Station Identification */ | ||
51 | #define TEST_CMD 0xe3 /* Test */ | ||
52 | |||
53 | /* Unnumbered responses */ | ||
54 | #define RNRM_RSP 0x83 /* Request Normal Response Mode */ | ||
55 | #define UA_RSP 0x63 /* Unnumbered Acknowledgement */ | ||
56 | #define FRMR_RSP 0x87 /* Frame Reject */ | ||
57 | #define DM_RSP 0x0f /* Disconnect Mode */ | ||
58 | #define RD_RSP 0x43 /* Request Disconnection */ | ||
59 | #define XID_RSP 0xaf /* Exchange Station Identification */ | ||
60 | #define TEST_RSP 0xe3 /* Test frame */ | ||
61 | |||
62 | /* Supervisory (S) */ | ||
63 | #define RR 0x01 /* Receive Ready */ | ||
64 | #define REJ 0x09 /* Reject */ | ||
65 | #define RNR 0x05 /* Receive Not Ready */ | ||
66 | #define SREJ 0x0d /* Selective Reject */ | ||
67 | |||
68 | /* Information (I) */ | ||
69 | #define I_FRAME 0x00 /* Information Format */ | ||
70 | #define UI_FRAME 0x03 /* Unnumbered Information */ | ||
71 | |||
72 | #define CMD_FRAME 0x01 | ||
73 | #define RSP_FRAME 0x00 | ||
74 | |||
75 | #define PF_BIT 0x10 /* Poll/final bit */ | ||
76 | |||
77 | struct xid_frame { | ||
78 | __u8 caddr; /* Connection address */ | ||
79 | __u8 control; | ||
80 | __u8 ident; /* Should always be XID_FORMAT */ | ||
81 | __u32 saddr; /* Source device address */ | ||
82 | __u32 daddr; /* Destination device address */ | ||
83 | __u8 flags; /* Discovery flags */ | ||
84 | __u8 slotnr; | ||
85 | __u8 version; | ||
86 | } IRDA_PACK; | ||
87 | |||
88 | struct test_frame { | ||
89 | __u8 caddr; /* Connection address */ | ||
90 | __u8 control; | ||
91 | __u32 saddr; /* Source device address */ | ||
92 | __u32 daddr; /* Destination device address */ | ||
93 | } IRDA_PACK; | ||
94 | |||
95 | struct ua_frame { | ||
96 | __u8 caddr; | ||
97 | __u8 control; | ||
98 | |||
99 | __u32 saddr; /* Source device address */ | ||
100 | __u32 daddr; /* Dest device address */ | ||
101 | } IRDA_PACK; | ||
102 | |||
103 | struct i_frame { | ||
104 | __u8 caddr; | ||
105 | __u8 control; | ||
106 | } IRDA_PACK; | ||
107 | |||
108 | struct snrm_frame { | ||
109 | __u8 caddr; | ||
110 | __u8 control; | ||
111 | __u32 saddr; | ||
112 | __u32 daddr; | ||
113 | __u8 ncaddr; | ||
114 | } IRDA_PACK; | ||
115 | |||
116 | void irlap_queue_xmit(struct irlap_cb *self, struct sk_buff *skb); | ||
117 | void irlap_send_discovery_xid_frame(struct irlap_cb *, int S, __u8 s, | ||
118 | __u8 command, | ||
119 | struct discovery_t *discovery); | ||
120 | void irlap_send_snrm_frame(struct irlap_cb *, struct qos_info *); | ||
121 | void irlap_send_test_frame(struct irlap_cb *self, __u8 caddr, __u32 daddr, | ||
122 | struct sk_buff *cmd); | ||
123 | void irlap_send_ua_response_frame(struct irlap_cb *, struct qos_info *); | ||
124 | void irlap_send_dm_frame(struct irlap_cb *self); | ||
125 | void irlap_send_rd_frame(struct irlap_cb *self); | ||
126 | void irlap_send_disc_frame(struct irlap_cb *self); | ||
127 | void irlap_send_rr_frame(struct irlap_cb *self, int command); | ||
128 | |||
129 | void irlap_send_data_primary(struct irlap_cb *, struct sk_buff *); | ||
130 | void irlap_send_data_primary_poll(struct irlap_cb *, struct sk_buff *); | ||
131 | void irlap_send_data_secondary(struct irlap_cb *, struct sk_buff *); | ||
132 | void irlap_send_data_secondary_final(struct irlap_cb *, struct sk_buff *); | ||
133 | void irlap_resend_rejected_frames(struct irlap_cb *, int command); | ||
134 | void irlap_resend_rejected_frame(struct irlap_cb *self, int command); | ||
135 | |||
136 | void irlap_send_ui_frame(struct irlap_cb *self, struct sk_buff *skb, | ||
137 | __u8 caddr, int command); | ||
138 | |||
139 | extern int irlap_insert_qos_negotiation_params(struct irlap_cb *self, | ||
140 | struct sk_buff *skb); | ||
141 | |||
142 | #endif | ||
diff --git a/include/net/irda/irlmp.h b/include/net/irda/irlmp.h new file mode 100644 index 000000000000..86aefb1fda5e --- /dev/null +++ b/include/net/irda/irlmp.h | |||
@@ -0,0 +1,295 @@ | |||
1 | /********************************************************************* | ||
2 | * | ||
3 | * Filename: irlmp.h | ||
4 | * Version: 0.9 | ||
5 | * Description: IrDA Link Management Protocol (LMP) layer | ||
6 | * Status: Experimental. | ||
7 | * Author: Dag Brattli <dagb@cs.uit.no> | ||
8 | * Created at: Sun Aug 17 20:54:32 1997 | ||
9 | * Modified at: Fri Dec 10 13:23:01 1999 | ||
10 | * Modified by: Dag Brattli <dagb@cs.uit.no> | ||
11 | * | ||
12 | * Copyright (c) 1998-1999 Dag Brattli <dagb@cs.uit.no>, | ||
13 | * All Rights Reserved. | ||
14 | * Copyright (c) 2000-2002 Jean Tourrilhes <jt@hpl.hp.com> | ||
15 | * | ||
16 | * This program is free software; you can redistribute it and/or | ||
17 | * modify it under the terms of the GNU General Public License as | ||
18 | * published by the Free Software Foundation; either version 2 of | ||
19 | * the License, or (at your option) any later version. | ||
20 | * | ||
21 | * Neither Dag Brattli nor University of Tromsų admit liability nor | ||
22 | * provide warranty for any of this software. This material is | ||
23 | * provided "AS-IS" and at no charge. | ||
24 | * | ||
25 | ********************************************************************/ | ||
26 | |||
27 | #ifndef IRLMP_H | ||
28 | #define IRLMP_H | ||
29 | |||
30 | #include <asm/param.h> /* for HZ */ | ||
31 | |||
32 | #include <linux/config.h> | ||
33 | #include <linux/types.h> | ||
34 | |||
35 | #include <net/irda/irda.h> | ||
36 | #include <net/irda/qos.h> | ||
37 | #include <net/irda/irlap.h> /* LAP_MAX_HEADER, ... */ | ||
38 | #include <net/irda/irlmp_event.h> | ||
39 | #include <net/irda/irqueue.h> | ||
40 | #include <net/irda/discovery.h> | ||
41 | |||
42 | /* LSAP-SEL's */ | ||
43 | #define LSAP_MASK 0x7f | ||
44 | #define LSAP_IAS 0x00 | ||
45 | #define LSAP_ANY 0xff | ||
46 | #define LSAP_MAX 0x6f /* 0x70-0x7f are reserved */ | ||
47 | #define LSAP_CONNLESS 0x70 /* Connectionless LSAP, mostly used for Ultra */ | ||
48 | |||
49 | #define DEV_ADDR_ANY 0xffffffff | ||
50 | |||
51 | #define LMP_HEADER 2 /* Dest LSAP + Source LSAP */ | ||
52 | #define LMP_CONTROL_HEADER 4 | ||
53 | #define LMP_PID_HEADER 1 /* Used by Ultra */ | ||
54 | #define LMP_MAX_HEADER (LMP_CONTROL_HEADER+LAP_MAX_HEADER) | ||
55 | |||
56 | #define LM_MAX_CONNECTIONS 10 | ||
57 | |||
58 | #define LM_IDLE_TIMEOUT 2*HZ /* 2 seconds for now */ | ||
59 | |||
60 | typedef enum { | ||
61 | S_PNP = 0, | ||
62 | S_PDA, | ||
63 | S_COMPUTER, | ||
64 | S_PRINTER, | ||
65 | S_MODEM, | ||
66 | S_FAX, | ||
67 | S_LAN, | ||
68 | S_TELEPHONY, | ||
69 | S_COMM, | ||
70 | S_OBEX, | ||
71 | S_ANY, | ||
72 | S_END, | ||
73 | } SERVICE; | ||
74 | |||
75 | /* For selective discovery */ | ||
76 | typedef void (*DISCOVERY_CALLBACK1) (discinfo_t *, DISCOVERY_MODE, void *); | ||
77 | /* For expiry (the same) */ | ||
78 | typedef void (*DISCOVERY_CALLBACK2) (discinfo_t *, DISCOVERY_MODE, void *); | ||
79 | |||
80 | typedef struct { | ||
81 | irda_queue_t queue; /* Must be first */ | ||
82 | |||
83 | __u16_host_order hints; /* Hint bits */ | ||
84 | } irlmp_service_t; | ||
85 | |||
86 | typedef struct { | ||
87 | irda_queue_t queue; /* Must be first */ | ||
88 | |||
89 | __u16_host_order hint_mask; | ||
90 | |||
91 | DISCOVERY_CALLBACK1 disco_callback; /* Selective discovery */ | ||
92 | DISCOVERY_CALLBACK2 expir_callback; /* Selective expiration */ | ||
93 | void *priv; /* Used to identify client */ | ||
94 | } irlmp_client_t; | ||
95 | |||
96 | /* | ||
97 | * Information about each logical LSAP connection | ||
98 | */ | ||
99 | struct lsap_cb { | ||
100 | irda_queue_t queue; /* Must be first */ | ||
101 | magic_t magic; | ||
102 | |||
103 | unsigned long connected; /* set_bit used on this */ | ||
104 | int persistent; | ||
105 | |||
106 | __u8 slsap_sel; /* Source (this) LSAP address */ | ||
107 | __u8 dlsap_sel; /* Destination LSAP address (if connected) */ | ||
108 | #ifdef CONFIG_IRDA_ULTRA | ||
109 | __u8 pid; /* Used by connectionless LSAP */ | ||
110 | #endif /* CONFIG_IRDA_ULTRA */ | ||
111 | struct sk_buff *conn_skb; /* Store skb here while connecting */ | ||
112 | |||
113 | struct timer_list watchdog_timer; | ||
114 | |||
115 | IRLMP_STATE lsap_state; /* Connection state */ | ||
116 | notify_t notify; /* Indication/Confirm entry points */ | ||
117 | struct qos_info qos; /* QoS for this connection */ | ||
118 | |||
119 | struct lap_cb *lap; /* Pointer to LAP connection structure */ | ||
120 | }; | ||
121 | |||
122 | /* | ||
123 | * Used for caching the last slsap->dlsap->handle mapping | ||
124 | * | ||
125 | * We don't need to keep/match the remote address in the cache because | ||
126 | * we are associated with a specific LAP (which implies it). | ||
127 | * Jean II | ||
128 | */ | ||
129 | typedef struct { | ||
130 | int valid; | ||
131 | |||
132 | __u8 slsap_sel; | ||
133 | __u8 dlsap_sel; | ||
134 | struct lsap_cb *lsap; | ||
135 | } CACHE_ENTRY; | ||
136 | |||
137 | /* | ||
138 | * Information about each registred IrLAP layer | ||
139 | */ | ||
140 | struct lap_cb { | ||
141 | irda_queue_t queue; /* Must be first */ | ||
142 | magic_t magic; | ||
143 | |||
144 | int reason; /* LAP disconnect reason */ | ||
145 | |||
146 | IRLMP_STATE lap_state; | ||
147 | |||
148 | struct irlap_cb *irlap; /* Instance of IrLAP layer */ | ||
149 | hashbin_t *lsaps; /* LSAP associated with this link */ | ||
150 | struct lsap_cb *flow_next; /* Next lsap to be polled for Tx */ | ||
151 | |||
152 | __u8 caddr; /* Connection address */ | ||
153 | __u32 saddr; /* Source device address */ | ||
154 | __u32 daddr; /* Destination device address */ | ||
155 | |||
156 | struct qos_info *qos; /* LAP QoS for this session */ | ||
157 | struct timer_list idle_timer; | ||
158 | |||
159 | #ifdef CONFIG_IRDA_CACHE_LAST_LSAP | ||
160 | /* The lsap cache was moved from struct irlmp_cb to here because | ||
161 | * it must be associated with the specific LAP. Also, this | ||
162 | * improves performance. - Jean II */ | ||
163 | CACHE_ENTRY cache; /* Caching last slsap->dlsap->handle mapping */ | ||
164 | #endif | ||
165 | }; | ||
166 | |||
167 | /* | ||
168 | * Main structure for IrLMP | ||
169 | */ | ||
170 | struct irlmp_cb { | ||
171 | magic_t magic; | ||
172 | |||
173 | __u8 conflict_flag; | ||
174 | |||
175 | discovery_t discovery_cmd; /* Discovery command to use by IrLAP */ | ||
176 | discovery_t discovery_rsp; /* Discovery response to use by IrLAP */ | ||
177 | |||
178 | /* Last lsap picked automatically by irlmp_find_free_slsap() */ | ||
179 | int last_lsap_sel; | ||
180 | |||
181 | struct timer_list discovery_timer; | ||
182 | |||
183 | hashbin_t *links; /* IrLAP connection table */ | ||
184 | hashbin_t *unconnected_lsaps; | ||
185 | hashbin_t *clients; | ||
186 | hashbin_t *services; | ||
187 | |||
188 | hashbin_t *cachelog; /* Current discovery log */ | ||
189 | |||
190 | int running; | ||
191 | |||
192 | __u16_host_order hints; /* Hint bits */ | ||
193 | }; | ||
194 | |||
195 | /* Prototype declarations */ | ||
196 | int irlmp_init(void); | ||
197 | void irlmp_cleanup(void); | ||
198 | struct lsap_cb *irlmp_open_lsap(__u8 slsap, notify_t *notify, __u8 pid); | ||
199 | void irlmp_close_lsap( struct lsap_cb *self); | ||
200 | |||
201 | __u16 irlmp_service_to_hint(int service); | ||
202 | void *irlmp_register_service(__u16 hints); | ||
203 | int irlmp_unregister_service(void *handle); | ||
204 | void *irlmp_register_client(__u16 hint_mask, DISCOVERY_CALLBACK1 disco_clb, | ||
205 | DISCOVERY_CALLBACK2 expir_clb, void *priv); | ||
206 | int irlmp_unregister_client(void *handle); | ||
207 | int irlmp_update_client(void *handle, __u16 hint_mask, | ||
208 | DISCOVERY_CALLBACK1 disco_clb, | ||
209 | DISCOVERY_CALLBACK2 expir_clb, void *priv); | ||
210 | |||
211 | void irlmp_register_link(struct irlap_cb *, __u32 saddr, notify_t *); | ||
212 | void irlmp_unregister_link(__u32 saddr); | ||
213 | |||
214 | int irlmp_connect_request(struct lsap_cb *, __u8 dlsap_sel, | ||
215 | __u32 saddr, __u32 daddr, | ||
216 | struct qos_info *, struct sk_buff *); | ||
217 | void irlmp_connect_indication(struct lsap_cb *self, struct sk_buff *skb); | ||
218 | int irlmp_connect_response(struct lsap_cb *, struct sk_buff *); | ||
219 | void irlmp_connect_confirm(struct lsap_cb *, struct sk_buff *); | ||
220 | struct lsap_cb *irlmp_dup(struct lsap_cb *self, void *instance); | ||
221 | |||
222 | void irlmp_disconnect_indication(struct lsap_cb *self, LM_REASON reason, | ||
223 | struct sk_buff *userdata); | ||
224 | int irlmp_disconnect_request(struct lsap_cb *, struct sk_buff *userdata); | ||
225 | |||
226 | void irlmp_discovery_confirm(hashbin_t *discovery_log, DISCOVERY_MODE mode); | ||
227 | void irlmp_discovery_request(int nslots); | ||
228 | discinfo_t *irlmp_get_discoveries(int *pn, __u16 mask, int nslots); | ||
229 | void irlmp_do_expiry(void); | ||
230 | void irlmp_do_discovery(int nslots); | ||
231 | discovery_t *irlmp_get_discovery_response(void); | ||
232 | void irlmp_discovery_expiry(discinfo_t *expiry, int number); | ||
233 | |||
234 | int irlmp_data_request(struct lsap_cb *, struct sk_buff *); | ||
235 | void irlmp_data_indication(struct lsap_cb *, struct sk_buff *); | ||
236 | |||
237 | int irlmp_udata_request(struct lsap_cb *, struct sk_buff *); | ||
238 | void irlmp_udata_indication(struct lsap_cb *, struct sk_buff *); | ||
239 | |||
240 | #ifdef CONFIG_IRDA_ULTRA | ||
241 | int irlmp_connless_data_request(struct lsap_cb *, struct sk_buff *, __u8); | ||
242 | void irlmp_connless_data_indication(struct lsap_cb *, struct sk_buff *); | ||
243 | #endif /* CONFIG_IRDA_ULTRA */ | ||
244 | |||
245 | void irlmp_status_indication(struct lap_cb *, LINK_STATUS link, LOCK_STATUS lock); | ||
246 | void irlmp_flow_indication(struct lap_cb *self, LOCAL_FLOW flow); | ||
247 | |||
248 | LM_REASON irlmp_convert_lap_reason(LAP_REASON); | ||
249 | |||
250 | static inline __u32 irlmp_get_saddr(const struct lsap_cb *self) | ||
251 | { | ||
252 | return (self && self->lap) ? self->lap->saddr : 0; | ||
253 | } | ||
254 | |||
255 | static inline __u32 irlmp_get_daddr(const struct lsap_cb *self) | ||
256 | { | ||
257 | return (self && self->lap) ? self->lap->daddr : 0; | ||
258 | } | ||
259 | |||
260 | extern const char *irlmp_reasons[]; | ||
261 | extern int sysctl_discovery_timeout; | ||
262 | extern int sysctl_discovery_slots; | ||
263 | extern int sysctl_discovery; | ||
264 | extern int sysctl_lap_keepalive_time; /* in ms, default is LM_IDLE_TIMEOUT */ | ||
265 | extern struct irlmp_cb *irlmp; | ||
266 | |||
267 | /* Check if LAP queue is full. | ||
268 | * Used by IrTTP for low control, see comments in irlap.h - Jean II */ | ||
269 | static inline int irlmp_lap_tx_queue_full(struct lsap_cb *self) | ||
270 | { | ||
271 | if (self == NULL) | ||
272 | return 0; | ||
273 | if (self->lap == NULL) | ||
274 | return 0; | ||
275 | if (self->lap->irlap == NULL) | ||
276 | return 0; | ||
277 | |||
278 | return(IRLAP_GET_TX_QUEUE_LEN(self->lap->irlap) >= LAP_HIGH_THRESHOLD); | ||
279 | } | ||
280 | |||
281 | /* After doing a irlmp_dup(), this get one of the two socket back into | ||
282 | * a state where it's waiting incomming connections. | ||
283 | * Note : this can be used *only* if the socket is not yet connected | ||
284 | * (i.e. NO irlmp_connect_response() done on this socket). | ||
285 | * - Jean II */ | ||
286 | static inline void irlmp_listen(struct lsap_cb *self) | ||
287 | { | ||
288 | self->dlsap_sel = LSAP_ANY; | ||
289 | self->lap = NULL; | ||
290 | self->lsap_state = LSAP_DISCONNECTED; | ||
291 | /* Started when we received the LM_CONNECT_INDICATION */ | ||
292 | del_timer(&self->watchdog_timer); | ||
293 | } | ||
294 | |||
295 | #endif | ||
diff --git a/include/net/irda/irlmp_event.h b/include/net/irda/irlmp_event.h new file mode 100644 index 000000000000..03c6f81a502a --- /dev/null +++ b/include/net/irda/irlmp_event.h | |||
@@ -0,0 +1,98 @@ | |||
1 | /********************************************************************* | ||
2 | * | ||
3 | * Filename: irlmp_event.h | ||
4 | * Version: 0.1 | ||
5 | * Description: IrDA-LMP event handling | ||
6 | * Status: Experimental. | ||
7 | * Author: Dag Brattli <dagb@cs.uit.no> | ||
8 | * Created at: Mon Aug 4 20:40:53 1997 | ||
9 | * Modified at: Thu Jul 8 12:18:54 1999 | ||
10 | * Modified by: Dag Brattli <dagb@cs.uit.no> | ||
11 | * | ||
12 | * Copyright (c) 1997, 1999 Dag Brattli <dagb@cs.uit.no>, | ||
13 | * All Rights Reserved. | ||
14 | * Copyright (c) 2000-2002 Jean Tourrilhes <jt@hpl.hp.com> | ||
15 | * | ||
16 | * This program is free software; you can redistribute it and/or | ||
17 | * modify it under the terms of the GNU General Public License as | ||
18 | * published by the Free Software Foundation; either version 2 of | ||
19 | * the License, or (at your option) any later version. | ||
20 | * | ||
21 | * Neither Dag Brattli nor University of Tromsų admit liability nor | ||
22 | * provide warranty for any of this software. This material is | ||
23 | * provided "AS-IS" and at no charge. | ||
24 | * | ||
25 | ********************************************************************/ | ||
26 | |||
27 | #ifndef IRLMP_EVENT_H | ||
28 | #define IRLMP_EVENT_H | ||
29 | |||
30 | /* A few forward declarations (to make compiler happy) */ | ||
31 | struct irlmp_cb; | ||
32 | struct lsap_cb; | ||
33 | struct lap_cb; | ||
34 | struct discovery_t; | ||
35 | |||
36 | /* LAP states */ | ||
37 | typedef enum { | ||
38 | /* IrLAP connection control states */ | ||
39 | LAP_STANDBY, /* No LAP connection */ | ||
40 | LAP_U_CONNECT, /* Starting LAP connection */ | ||
41 | LAP_ACTIVE, /* LAP connection is active */ | ||
42 | } IRLMP_STATE; | ||
43 | |||
44 | /* LSAP connection control states */ | ||
45 | typedef enum { | ||
46 | LSAP_DISCONNECTED, /* No LSAP connection */ | ||
47 | LSAP_CONNECT, /* Connect indication from peer */ | ||
48 | LSAP_CONNECT_PEND, /* Connect request from service user */ | ||
49 | LSAP_DATA_TRANSFER_READY, /* LSAP connection established */ | ||
50 | LSAP_SETUP, /* Trying to set up LSAP connection */ | ||
51 | LSAP_SETUP_PEND, /* Request to start LAP connection */ | ||
52 | } LSAP_STATE; | ||
53 | |||
54 | typedef enum { | ||
55 | /* LSAP events */ | ||
56 | LM_CONNECT_REQUEST, | ||
57 | LM_CONNECT_CONFIRM, | ||
58 | LM_CONNECT_RESPONSE, | ||
59 | LM_CONNECT_INDICATION, | ||
60 | |||
61 | LM_DISCONNECT_INDICATION, | ||
62 | LM_DISCONNECT_REQUEST, | ||
63 | |||
64 | LM_DATA_REQUEST, | ||
65 | LM_UDATA_REQUEST, | ||
66 | LM_DATA_INDICATION, | ||
67 | LM_UDATA_INDICATION, | ||
68 | |||
69 | LM_WATCHDOG_TIMEOUT, | ||
70 | |||
71 | /* IrLAP events */ | ||
72 | LM_LAP_CONNECT_REQUEST, | ||
73 | LM_LAP_CONNECT_INDICATION, | ||
74 | LM_LAP_CONNECT_CONFIRM, | ||
75 | LM_LAP_DISCONNECT_INDICATION, | ||
76 | LM_LAP_DISCONNECT_REQUEST, | ||
77 | LM_LAP_DISCOVERY_REQUEST, | ||
78 | LM_LAP_DISCOVERY_CONFIRM, | ||
79 | LM_LAP_IDLE_TIMEOUT, | ||
80 | } IRLMP_EVENT; | ||
81 | |||
82 | extern const char *irlmp_state[]; | ||
83 | extern const char *irlsap_state[]; | ||
84 | |||
85 | void irlmp_watchdog_timer_expired(void *data); | ||
86 | void irlmp_discovery_timer_expired(void *data); | ||
87 | void irlmp_idle_timer_expired(void *data); | ||
88 | |||
89 | void irlmp_do_lap_event(struct lap_cb *self, IRLMP_EVENT event, | ||
90 | struct sk_buff *skb); | ||
91 | int irlmp_do_lsap_event(struct lsap_cb *self, IRLMP_EVENT event, | ||
92 | struct sk_buff *skb); | ||
93 | |||
94 | #endif /* IRLMP_EVENT_H */ | ||
95 | |||
96 | |||
97 | |||
98 | |||
diff --git a/include/net/irda/irlmp_frame.h b/include/net/irda/irlmp_frame.h new file mode 100644 index 000000000000..eb3ad158c023 --- /dev/null +++ b/include/net/irda/irlmp_frame.h | |||
@@ -0,0 +1,63 @@ | |||
1 | /********************************************************************* | ||
2 | * | ||
3 | * Filename: irlmp_frame.h | ||
4 | * Version: 0.9 | ||
5 | * Description: | ||
6 | * Status: Experimental. | ||
7 | * Author: Dag Brattli <dagb@cs.uit.no> | ||
8 | * Created at: Tue Aug 19 02:09:59 1997 | ||
9 | * Modified at: Fri Dec 10 13:21:53 1999 | ||
10 | * Modified by: Dag Brattli <dagb@cs.uit.no> | ||
11 | * | ||
12 | * Copyright (c) 1997, 1999 Dag Brattli <dagb@cs.uit.no>, | ||
13 | * All Rights Reserved. | ||
14 | * | ||
15 | * This program is free software; you can redistribute it and/or | ||
16 | * modify it under the terms of the GNU General Public License as | ||
17 | * published by the Free Software Foundation; either version 2 of | ||
18 | * the License, or (at your option) any later version. | ||
19 | * | ||
20 | * Neither Dag Brattli nor University of Tromsų admit liability nor | ||
21 | * provide warranty for any of this software. This material is | ||
22 | * provided "AS-IS" and at no charge. | ||
23 | * | ||
24 | ********************************************************************/ | ||
25 | |||
26 | #ifndef IRMLP_FRAME_H | ||
27 | #define IRMLP_FRAME_H | ||
28 | |||
29 | #include <linux/config.h> | ||
30 | #include <linux/skbuff.h> | ||
31 | |||
32 | #include <net/irda/discovery.h> | ||
33 | |||
34 | /* IrLMP frame opcodes */ | ||
35 | #define CONNECT_CMD 0x01 | ||
36 | #define CONNECT_CNF 0x81 | ||
37 | #define DISCONNECT 0x02 | ||
38 | #define ACCESSMODE_CMD 0x03 | ||
39 | #define ACCESSMODE_CNF 0x83 | ||
40 | |||
41 | #define CONTROL_BIT 0x80 | ||
42 | |||
43 | void irlmp_send_data_pdu(struct lap_cb *self, __u8 dlsap, __u8 slsap, | ||
44 | int expedited, struct sk_buff *skb); | ||
45 | void irlmp_send_lcf_pdu(struct lap_cb *self, __u8 dlsap, __u8 slsap, | ||
46 | __u8 opcode, struct sk_buff *skb); | ||
47 | void irlmp_link_data_indication(struct lap_cb *, struct sk_buff *, | ||
48 | int unreliable); | ||
49 | #ifdef CONFIG_IRDA_ULTRA | ||
50 | void irlmp_link_unitdata_indication(struct lap_cb *, struct sk_buff *); | ||
51 | #endif /* CONFIG_IRDA_ULTRA */ | ||
52 | |||
53 | void irlmp_link_connect_indication(struct lap_cb *, __u32 saddr, __u32 daddr, | ||
54 | struct qos_info *qos, struct sk_buff *skb); | ||
55 | void irlmp_link_connect_request(__u32 daddr); | ||
56 | void irlmp_link_connect_confirm(struct lap_cb *self, struct qos_info *qos, | ||
57 | struct sk_buff *skb); | ||
58 | void irlmp_link_disconnect_indication(struct lap_cb *, struct irlap_cb *, | ||
59 | LAP_REASON reason, struct sk_buff *); | ||
60 | void irlmp_link_discovery_confirm(struct lap_cb *self, hashbin_t *log); | ||
61 | void irlmp_link_discovery_indication(struct lap_cb *, discovery_t *discovery); | ||
62 | |||
63 | #endif | ||
diff --git a/include/net/irda/irmod.h b/include/net/irda/irmod.h new file mode 100644 index 000000000000..72b446c1e22c --- /dev/null +++ b/include/net/irda/irmod.h | |||
@@ -0,0 +1,109 @@ | |||
1 | /********************************************************************* | ||
2 | * | ||
3 | * Filename: irmod.h | ||
4 | * Version: 0.3 | ||
5 | * Description: IrDA module and utilities functions | ||
6 | * Status: Experimental. | ||
7 | * Author: Dag Brattli <dagb@cs.uit.no> | ||
8 | * Created at: Mon Dec 15 13:58:52 1997 | ||
9 | * Modified at: Fri Jan 28 13:15:24 2000 | ||
10 | * Modified by: Dag Brattli <dagb@cs.uit.no> | ||
11 | * | ||
12 | * Copyright (c) 1998-2000 Dag Brattli, All Rights Reserved. | ||
13 | * Copyright (c) 2000-2002 Jean Tourrilhes <jt@hpl.hp.com> | ||
14 | * | ||
15 | * This program is free software; you can redistribute it and/or | ||
16 | * modify it under the terms of the GNU General Public License as | ||
17 | * published by the Free Software Foundation; either version 2 of | ||
18 | * the License, or (at your option) any later version. | ||
19 | * | ||
20 | * Neither Dag Brattli nor University of Tromsų admit liability nor | ||
21 | * provide warranty for any of this software. This material is | ||
22 | * provided "AS-IS" and at no charg. | ||
23 | * | ||
24 | ********************************************************************/ | ||
25 | |||
26 | #ifndef IRMOD_H | ||
27 | #define IRMOD_H | ||
28 | |||
29 | /* Misc status information */ | ||
30 | typedef enum { | ||
31 | STATUS_OK, | ||
32 | STATUS_ABORTED, | ||
33 | STATUS_NO_ACTIVITY, | ||
34 | STATUS_NOISY, | ||
35 | STATUS_REMOTE, | ||
36 | } LINK_STATUS; | ||
37 | |||
38 | typedef enum { | ||
39 | LOCK_NO_CHANGE, | ||
40 | LOCK_LOCKED, | ||
41 | LOCK_UNLOCKED, | ||
42 | } LOCK_STATUS; | ||
43 | |||
44 | typedef enum { FLOW_STOP, FLOW_START } LOCAL_FLOW; | ||
45 | |||
46 | /* | ||
47 | * IrLMP disconnect reasons. The order is very important, since they | ||
48 | * correspond to disconnect reasons sent in IrLMP disconnect frames, so | ||
49 | * please do not touch :-) | ||
50 | */ | ||
51 | typedef enum { | ||
52 | LM_USER_REQUEST = 1, /* User request */ | ||
53 | LM_LAP_DISCONNECT, /* Unexpected IrLAP disconnect */ | ||
54 | LM_CONNECT_FAILURE, /* Failed to establish IrLAP connection */ | ||
55 | LM_LAP_RESET, /* IrLAP reset */ | ||
56 | LM_INIT_DISCONNECT, /* Link Management initiated disconnect */ | ||
57 | LM_LSAP_NOTCONN, /* Data delivered on unconnected LSAP */ | ||
58 | LM_NON_RESP_CLIENT, /* Non responsive LM-MUX client */ | ||
59 | LM_NO_AVAIL_CLIENT, /* No available LM-MUX client */ | ||
60 | LM_CONN_HALF_OPEN, /* Connection is half open */ | ||
61 | LM_BAD_SOURCE_ADDR, /* Illegal source address (i.e 0x00) */ | ||
62 | } LM_REASON; | ||
63 | #define LM_UNKNOWN 0xff /* Unspecified disconnect reason */ | ||
64 | |||
65 | /* A few forward declarations (to make compiler happy) */ | ||
66 | struct qos_info; /* in <net/irda/qos.h> */ | ||
67 | |||
68 | /* | ||
69 | * Notify structure used between transport and link management layers | ||
70 | */ | ||
71 | typedef struct { | ||
72 | int (*data_indication)(void *priv, void *sap, struct sk_buff *skb); | ||
73 | int (*udata_indication)(void *priv, void *sap, struct sk_buff *skb); | ||
74 | void (*connect_confirm)(void *instance, void *sap, | ||
75 | struct qos_info *qos, __u32 max_sdu_size, | ||
76 | __u8 max_header_size, struct sk_buff *skb); | ||
77 | void (*connect_indication)(void *instance, void *sap, | ||
78 | struct qos_info *qos, __u32 max_sdu_size, | ||
79 | __u8 max_header_size, struct sk_buff *skb); | ||
80 | void (*disconnect_indication)(void *instance, void *sap, | ||
81 | LM_REASON reason, struct sk_buff *); | ||
82 | void (*flow_indication)(void *instance, void *sap, LOCAL_FLOW flow); | ||
83 | void (*status_indication)(void *instance, | ||
84 | LINK_STATUS link, LOCK_STATUS lock); | ||
85 | void *instance; /* Layer instance pointer */ | ||
86 | char name[16]; /* Name of layer */ | ||
87 | } notify_t; | ||
88 | |||
89 | #define NOTIFY_MAX_NAME 16 | ||
90 | |||
91 | /* Zero the notify structure */ | ||
92 | void irda_notify_init(notify_t *notify); | ||
93 | |||
94 | /* Locking wrapper - Note the inverted logic on irda_lock(). | ||
95 | * Those function basically return false if the lock is already in the | ||
96 | * position you want to set it. - Jean II */ | ||
97 | #define irda_lock(lock) (! test_and_set_bit(0, (void *) (lock))) | ||
98 | #define irda_unlock(lock) (test_and_clear_bit(0, (void *) (lock))) | ||
99 | |||
100 | #endif /* IRMOD_H */ | ||
101 | |||
102 | |||
103 | |||
104 | |||
105 | |||
106 | |||
107 | |||
108 | |||
109 | |||
diff --git a/include/net/irda/irqueue.h b/include/net/irda/irqueue.h new file mode 100644 index 000000000000..335b0ace9665 --- /dev/null +++ b/include/net/irda/irqueue.h | |||
@@ -0,0 +1,96 @@ | |||
1 | /********************************************************************* | ||
2 | * | ||
3 | * Filename: irqueue.h | ||
4 | * Version: 0.3 | ||
5 | * Description: General queue implementation | ||
6 | * Status: Experimental. | ||
7 | * Author: Dag Brattli <dagb@cs.uit.no> | ||
8 | * Created at: Tue Jun 9 13:26:50 1998 | ||
9 | * Modified at: Thu Oct 7 13:25:16 1999 | ||
10 | * Modified by: Dag Brattli <dagb@cs.uit.no> | ||
11 | * | ||
12 | * Copyright (C) 1998-1999, Aage Kvalnes <aage@cs.uit.no> | ||
13 | * Copyright (c) 1998, Dag Brattli | ||
14 | * All Rights Reserved. | ||
15 | * | ||
16 | * This code is taken from the Vortex Operating System written by Aage | ||
17 | * Kvalnes and has been ported to Linux and Linux/IR by Dag Brattli | ||
18 | * | ||
19 | * This program is free software; you can redistribute it and/or | ||
20 | * modify it under the terms of the GNU General Public License as | ||
21 | * published by the Free Software Foundation; either version 2 of | ||
22 | * the License, or (at your option) any later version. | ||
23 | * | ||
24 | * Neither Dag Brattli nor University of Tromsų admit liability nor | ||
25 | * provide warranty for any of this software. This material is | ||
26 | * provided "AS-IS" and at no charge. | ||
27 | * | ||
28 | ********************************************************************/ | ||
29 | |||
30 | #include <linux/types.h> | ||
31 | #include <linux/spinlock.h> | ||
32 | |||
33 | #ifndef IRDA_QUEUE_H | ||
34 | #define IRDA_QUEUE_H | ||
35 | |||
36 | #define NAME_SIZE 32 | ||
37 | |||
38 | /* | ||
39 | * Hash types (some flags can be xored) | ||
40 | * See comments in irqueue.c for which one to use... | ||
41 | */ | ||
42 | #define HB_NOLOCK 0 /* No concurent access prevention */ | ||
43 | #define HB_LOCK 1 /* Prevent concurent write with global lock */ | ||
44 | |||
45 | /* | ||
46 | * Hash defines | ||
47 | */ | ||
48 | #define HASHBIN_SIZE 8 | ||
49 | #define HASHBIN_MASK 0x7 | ||
50 | |||
51 | #ifndef IRDA_ALIGN | ||
52 | #define IRDA_ALIGN __attribute__((aligned)) | ||
53 | #endif | ||
54 | |||
55 | #define Q_NULL { NULL, NULL, "", 0 } | ||
56 | |||
57 | typedef void (*FREE_FUNC)(void *arg); | ||
58 | |||
59 | struct irda_queue { | ||
60 | struct irda_queue *q_next; | ||
61 | struct irda_queue *q_prev; | ||
62 | |||
63 | char q_name[NAME_SIZE]; | ||
64 | long q_hash; /* Must be able to cast a (void *) */ | ||
65 | }; | ||
66 | typedef struct irda_queue irda_queue_t; | ||
67 | |||
68 | typedef struct hashbin_t { | ||
69 | __u32 magic; | ||
70 | int hb_type; | ||
71 | int hb_size; | ||
72 | spinlock_t hb_spinlock; /* HB_LOCK - Can be used by the user */ | ||
73 | |||
74 | irda_queue_t* hb_queue[HASHBIN_SIZE] IRDA_ALIGN; | ||
75 | |||
76 | irda_queue_t* hb_current; | ||
77 | } hashbin_t; | ||
78 | |||
79 | hashbin_t *hashbin_new(int type); | ||
80 | int hashbin_delete(hashbin_t* hashbin, FREE_FUNC func); | ||
81 | int hashbin_clear(hashbin_t* hashbin, FREE_FUNC free_func); | ||
82 | void hashbin_insert(hashbin_t* hashbin, irda_queue_t* entry, long hashv, | ||
83 | const char* name); | ||
84 | void* hashbin_remove(hashbin_t* hashbin, long hashv, const char* name); | ||
85 | void* hashbin_remove_first(hashbin_t *hashbin); | ||
86 | void* hashbin_remove_this( hashbin_t* hashbin, irda_queue_t* entry); | ||
87 | void* hashbin_find(hashbin_t* hashbin, long hashv, const char* name); | ||
88 | void* hashbin_lock_find(hashbin_t* hashbin, long hashv, const char* name); | ||
89 | void* hashbin_find_next(hashbin_t* hashbin, long hashv, const char* name, | ||
90 | void ** pnext); | ||
91 | irda_queue_t *hashbin_get_first(hashbin_t *hashbin); | ||
92 | irda_queue_t *hashbin_get_next(hashbin_t *hashbin); | ||
93 | |||
94 | #define HASHBIN_GET_SIZE(hashbin) hashbin->hb_size | ||
95 | |||
96 | #endif | ||
diff --git a/include/net/irda/irttp.h b/include/net/irda/irttp.h new file mode 100644 index 000000000000..a899e5837be8 --- /dev/null +++ b/include/net/irda/irttp.h | |||
@@ -0,0 +1,210 @@ | |||
1 | /********************************************************************* | ||
2 | * | ||
3 | * Filename: irttp.h | ||
4 | * Version: 1.0 | ||
5 | * Description: Tiny Transport Protocol (TTP) definitions | ||
6 | * Status: Experimental. | ||
7 | * Author: Dag Brattli <dagb@cs.uit.no> | ||
8 | * Created at: Sun Aug 31 20:14:31 1997 | ||
9 | * Modified at: Sun Dec 12 13:09:07 1999 | ||
10 | * Modified by: Dag Brattli <dagb@cs.uit.no> | ||
11 | * | ||
12 | * Copyright (c) 1998-1999 Dag Brattli <dagb@cs.uit.no>, | ||
13 | * All Rights Reserved. | ||
14 | * Copyright (c) 2000-2002 Jean Tourrilhes <jt@hpl.hp.com> | ||
15 | * | ||
16 | * This program is free software; you can redistribute it and/or | ||
17 | * modify it under the terms of the GNU General Public License as | ||
18 | * published by the Free Software Foundation; either version 2 of | ||
19 | * the License, or (at your option) any later version. | ||
20 | * | ||
21 | * Neither Dag Brattli nor University of Tromsų admit liability nor | ||
22 | * provide warranty for any of this software. This material is | ||
23 | * provided "AS-IS" and at no charge. | ||
24 | * | ||
25 | ********************************************************************/ | ||
26 | |||
27 | #ifndef IRTTP_H | ||
28 | #define IRTTP_H | ||
29 | |||
30 | #include <linux/types.h> | ||
31 | #include <linux/skbuff.h> | ||
32 | #include <linux/spinlock.h> | ||
33 | |||
34 | #include <net/irda/irda.h> | ||
35 | #include <net/irda/irlmp.h> /* struct lsap_cb */ | ||
36 | #include <net/irda/qos.h> /* struct qos_info */ | ||
37 | #include <net/irda/irqueue.h> | ||
38 | |||
39 | #define TTP_MAX_CONNECTIONS LM_MAX_CONNECTIONS | ||
40 | #define TTP_HEADER 1 | ||
41 | #define TTP_MAX_HEADER (TTP_HEADER + LMP_MAX_HEADER) | ||
42 | #define TTP_SAR_HEADER 5 | ||
43 | #define TTP_PARAMETERS 0x80 | ||
44 | #define TTP_MORE 0x80 | ||
45 | |||
46 | /* Transmission queue sizes */ | ||
47 | /* Worst case scenario, two window of data - Jean II */ | ||
48 | #define TTP_TX_MAX_QUEUE 14 | ||
49 | /* We need to keep at least 5 frames to make sure that we can refill | ||
50 | * appropriately the LAP layer. LAP keeps only two buffers, and we need | ||
51 | * to have 7 to make a full window - Jean II */ | ||
52 | #define TTP_TX_LOW_THRESHOLD 5 | ||
53 | /* Most clients are synchronous with respect to flow control, so we can | ||
54 | * keep a low number of Tx buffers in TTP - Jean II */ | ||
55 | #define TTP_TX_HIGH_THRESHOLD 7 | ||
56 | |||
57 | /* Receive queue sizes */ | ||
58 | /* Minimum of credit that the peer should hold. | ||
59 | * If the peer has less credits than 9 frames, we will explicitely send | ||
60 | * him some credits (through irttp_give_credit() and a specific frame). | ||
61 | * Note that when we give credits it's likely that it won't be sent in | ||
62 | * this LAP window, but in the next one. So, we make sure that the peer | ||
63 | * has something to send while waiting for credits (one LAP window == 7 | ||
64 | * + 1 frames while he process the credits). - Jean II */ | ||
65 | #define TTP_RX_MIN_CREDIT 8 | ||
66 | /* This is the default maximum number of credits held by the peer, so the | ||
67 | * default maximum number of frames he can send us before needing flow | ||
68 | * control answer from us (this may be negociated differently at TSAP setup). | ||
69 | * We want to minimise the number of times we have to explicitely send some | ||
70 | * credit to the peer, hoping we can piggyback it on the return data. In | ||
71 | * particular, it doesn't make sense for us to send credit more than once | ||
72 | * per LAP window. | ||
73 | * Moreover, giving credits has some latency, so we need strictly more than | ||
74 | * a LAP window, otherwise we may already have credits in our Tx queue. | ||
75 | * But on the other hand, we don't want to keep too many Rx buffer here | ||
76 | * before starting to flow control the other end, so make it exactly one | ||
77 | * LAP window + 1 + MIN_CREDITS. - Jean II */ | ||
78 | #define TTP_RX_DEFAULT_CREDIT 16 | ||
79 | /* Maximum number of credits we can allow the peer to have, and therefore | ||
80 | * maximum Rx queue size. | ||
81 | * Note that we try to deliver packets to the higher layer every time we | ||
82 | * receive something, so in normal mode the Rx queue will never contains | ||
83 | * more than one or two packets. - Jean II */ | ||
84 | #define TTP_RX_MAX_CREDIT 21 | ||
85 | |||
86 | /* What clients should use when calling ttp_open_tsap() */ | ||
87 | #define DEFAULT_INITIAL_CREDIT TTP_RX_DEFAULT_CREDIT | ||
88 | |||
89 | /* Some priorities for disconnect requests */ | ||
90 | #define P_NORMAL 0 | ||
91 | #define P_HIGH 1 | ||
92 | |||
93 | #define TTP_SAR_DISABLE 0 | ||
94 | #define TTP_SAR_UNBOUND 0xffffffff | ||
95 | |||
96 | /* Parameters */ | ||
97 | #define TTP_MAX_SDU_SIZE 0x01 | ||
98 | |||
99 | /* | ||
100 | * This structure contains all data assosiated with one instance of a TTP | ||
101 | * connection. | ||
102 | */ | ||
103 | struct tsap_cb { | ||
104 | irda_queue_t q; /* Must be first */ | ||
105 | magic_t magic; /* Just in case */ | ||
106 | |||
107 | __u8 stsap_sel; /* Source TSAP */ | ||
108 | __u8 dtsap_sel; /* Destination TSAP */ | ||
109 | |||
110 | struct lsap_cb *lsap; /* Corresponding LSAP to this TSAP */ | ||
111 | |||
112 | __u8 connected; /* TSAP connected */ | ||
113 | |||
114 | __u8 initial_credit; /* Initial credit to give peer */ | ||
115 | |||
116 | int avail_credit; /* Available credit to return to peer */ | ||
117 | int remote_credit; /* Credit held by peer TTP entity */ | ||
118 | int send_credit; /* Credit held by local TTP entity */ | ||
119 | |||
120 | struct sk_buff_head tx_queue; /* Frames to be transmitted */ | ||
121 | struct sk_buff_head rx_queue; /* Received frames */ | ||
122 | struct sk_buff_head rx_fragments; | ||
123 | int tx_queue_lock; | ||
124 | int rx_queue_lock; | ||
125 | spinlock_t lock; | ||
126 | |||
127 | notify_t notify; /* Callbacks to client layer */ | ||
128 | |||
129 | struct net_device_stats stats; | ||
130 | struct timer_list todo_timer; | ||
131 | |||
132 | __u32 max_seg_size; /* Max data that fit into an IrLAP frame */ | ||
133 | __u8 max_header_size; | ||
134 | |||
135 | int rx_sdu_busy; /* RxSdu.busy */ | ||
136 | __u32 rx_sdu_size; /* Current size of a partially received frame */ | ||
137 | __u32 rx_max_sdu_size; /* Max receive user data size */ | ||
138 | |||
139 | int tx_sdu_busy; /* TxSdu.busy */ | ||
140 | __u32 tx_max_sdu_size; /* Max transmit user data size */ | ||
141 | |||
142 | int close_pend; /* Close, but disconnect_pend */ | ||
143 | unsigned long disconnect_pend; /* Disconnect, but still data to send */ | ||
144 | struct sk_buff *disconnect_skb; | ||
145 | }; | ||
146 | |||
147 | struct irttp_cb { | ||
148 | magic_t magic; | ||
149 | hashbin_t *tsaps; | ||
150 | }; | ||
151 | |||
152 | int irttp_init(void); | ||
153 | void irttp_cleanup(void); | ||
154 | |||
155 | struct tsap_cb *irttp_open_tsap(__u8 stsap_sel, int credit, notify_t *notify); | ||
156 | int irttp_close_tsap(struct tsap_cb *self); | ||
157 | |||
158 | int irttp_data_request(struct tsap_cb *self, struct sk_buff *skb); | ||
159 | int irttp_udata_request(struct tsap_cb *self, struct sk_buff *skb); | ||
160 | |||
161 | int irttp_connect_request(struct tsap_cb *self, __u8 dtsap_sel, | ||
162 | __u32 saddr, __u32 daddr, | ||
163 | struct qos_info *qos, __u32 max_sdu_size, | ||
164 | struct sk_buff *userdata); | ||
165 | int irttp_connect_response(struct tsap_cb *self, __u32 max_sdu_size, | ||
166 | struct sk_buff *userdata); | ||
167 | int irttp_disconnect_request(struct tsap_cb *self, struct sk_buff *skb, | ||
168 | int priority); | ||
169 | void irttp_flow_request(struct tsap_cb *self, LOCAL_FLOW flow); | ||
170 | struct tsap_cb *irttp_dup(struct tsap_cb *self, void *instance); | ||
171 | |||
172 | static __inline __u32 irttp_get_saddr(struct tsap_cb *self) | ||
173 | { | ||
174 | return irlmp_get_saddr(self->lsap); | ||
175 | } | ||
176 | |||
177 | static __inline __u32 irttp_get_daddr(struct tsap_cb *self) | ||
178 | { | ||
179 | return irlmp_get_daddr(self->lsap); | ||
180 | } | ||
181 | |||
182 | static __inline __u32 irttp_get_max_seg_size(struct tsap_cb *self) | ||
183 | { | ||
184 | return self->max_seg_size; | ||
185 | } | ||
186 | |||
187 | /* After doing a irttp_dup(), this get one of the two socket back into | ||
188 | * a state where it's waiting incomming connections. | ||
189 | * Note : this can be used *only* if the socket is not yet connected | ||
190 | * (i.e. NO irttp_connect_response() done on this socket). | ||
191 | * - Jean II */ | ||
192 | static inline void irttp_listen(struct tsap_cb *self) | ||
193 | { | ||
194 | irlmp_listen(self->lsap); | ||
195 | self->dtsap_sel = LSAP_ANY; | ||
196 | } | ||
197 | |||
198 | /* Return TRUE if the node is in primary mode (i.e. master) | ||
199 | * - Jean II */ | ||
200 | static inline int irttp_is_primary(struct tsap_cb *self) | ||
201 | { | ||
202 | if ((self == NULL) || | ||
203 | (self->lsap == NULL) || | ||
204 | (self->lsap->lap == NULL) || | ||
205 | (self->lsap->lap->irlap == NULL)) | ||
206 | return -2; | ||
207 | return(irlap_is_primary(self->lsap->lap->irlap)); | ||
208 | } | ||
209 | |||
210 | #endif /* IRTTP_H */ | ||
diff --git a/include/net/irda/parameters.h b/include/net/irda/parameters.h new file mode 100644 index 000000000000..3a605d37ddbf --- /dev/null +++ b/include/net/irda/parameters.h | |||
@@ -0,0 +1,102 @@ | |||
1 | /********************************************************************* | ||
2 | * | ||
3 | * Filename: parameters.h | ||
4 | * Version: 1.0 | ||
5 | * Description: A more general way to handle (pi,pl,pv) parameters | ||
6 | * Status: Experimental. | ||
7 | * Author: Dag Brattli <dagb@cs.uit.no> | ||
8 | * Created at: Mon Jun 7 08:47:28 1999 | ||
9 | * Modified at: Sun Jan 30 14:05:14 2000 | ||
10 | * Modified by: Dag Brattli <dagb@cs.uit.no> | ||
11 | * | ||
12 | * Copyright (c) 1999-2000 Dag Brattli, All Rights Reserved. | ||
13 | * | ||
14 | * This program is free software; you can redistribute it and/or | ||
15 | * modify it under the terms of the GNU General Public License as | ||
16 | * published by the Free Software Foundation; either version 2 of | ||
17 | * the License, or (at your option) any later version. | ||
18 | * | ||
19 | * This program is distributed in the hope that it will be useful, | ||
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
22 | * GNU General Public License for more details. | ||
23 | * | ||
24 | * You should have received a copy of the GNU General Public License | ||
25 | * along with this program; if not, write to the Free Software | ||
26 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, | ||
27 | * MA 02111-1307 USA | ||
28 | * | ||
29 | * Michel Dänzer <daenzer@debian.org>, 10/2001 | ||
30 | * - simplify irda_pv_t to avoid endianness issues | ||
31 | * | ||
32 | ********************************************************************/ | ||
33 | |||
34 | #ifndef IRDA_PARAMS_H | ||
35 | #define IRDA_PARAMS_H | ||
36 | |||
37 | /* | ||
38 | * The currently supported types. Beware not to change the sequence since | ||
39 | * it a good reason why the sized integers has a value equal to their size | ||
40 | */ | ||
41 | typedef enum { | ||
42 | PV_INTEGER, /* Integer of any (pl) length */ | ||
43 | PV_INT_8_BITS, /* Integer of 8 bits in length */ | ||
44 | PV_INT_16_BITS, /* Integer of 16 bits in length */ | ||
45 | PV_STRING, /* \0 terminated string */ | ||
46 | PV_INT_32_BITS, /* Integer of 32 bits in length */ | ||
47 | PV_OCT_SEQ, /* Octet sequence */ | ||
48 | PV_NO_VALUE /* Does not contain any value (pl=0) */ | ||
49 | } PV_TYPE; | ||
50 | |||
51 | /* Bit 7 of type field */ | ||
52 | #define PV_BIG_ENDIAN 0x80 | ||
53 | #define PV_LITTLE_ENDIAN 0x00 | ||
54 | #define PV_MASK 0x7f /* To mask away endian bit */ | ||
55 | |||
56 | #define PV_PUT 0 | ||
57 | #define PV_GET 1 | ||
58 | |||
59 | typedef union { | ||
60 | char *c; | ||
61 | __u32 i; | ||
62 | __u32 *ip; | ||
63 | } irda_pv_t; | ||
64 | |||
65 | typedef struct { | ||
66 | __u8 pi; | ||
67 | __u8 pl; | ||
68 | irda_pv_t pv; | ||
69 | } irda_param_t; | ||
70 | |||
71 | typedef int (*PI_HANDLER)(void *self, irda_param_t *param, int get); | ||
72 | typedef int (*PV_HANDLER)(void *self, __u8 *buf, int len, __u8 pi, | ||
73 | PV_TYPE type, PI_HANDLER func); | ||
74 | |||
75 | typedef struct { | ||
76 | PI_HANDLER func; /* Handler for this parameter identifier */ | ||
77 | PV_TYPE type; /* Data type for this parameter */ | ||
78 | } pi_minor_info_t; | ||
79 | |||
80 | typedef struct { | ||
81 | pi_minor_info_t *pi_minor_call_table; | ||
82 | int len; | ||
83 | } pi_major_info_t; | ||
84 | |||
85 | typedef struct { | ||
86 | pi_major_info_t *tables; | ||
87 | int len; | ||
88 | __u8 pi_mask; | ||
89 | int pi_major_offset; | ||
90 | } pi_param_info_t; | ||
91 | |||
92 | int irda_param_pack(__u8 *buf, char *fmt, ...); | ||
93 | |||
94 | int irda_param_insert(void *self, __u8 pi, __u8 *buf, int len, | ||
95 | pi_param_info_t *info); | ||
96 | int irda_param_extract_all(void *self, __u8 *buf, int len, | ||
97 | pi_param_info_t *info); | ||
98 | |||
99 | #define irda_param_insert_byte(buf,pi,pv) irda_param_pack(buf,"bbb",pi,1,pv) | ||
100 | |||
101 | #endif /* IRDA_PARAMS_H */ | ||
102 | |||
diff --git a/include/net/irda/qos.h b/include/net/irda/qos.h new file mode 100644 index 000000000000..9ae3d6bc2423 --- /dev/null +++ b/include/net/irda/qos.h | |||
@@ -0,0 +1,104 @@ | |||
1 | /********************************************************************* | ||
2 | * | ||
3 | * Filename: qos.h | ||
4 | * Version: 1.0 | ||
5 | * Description: Quality of Service definitions | ||
6 | * Status: Experimental. | ||
7 | * Author: Dag Brattli <dagb@cs.uit.no> | ||
8 | * Created at: Fri Sep 19 23:21:09 1997 | ||
9 | * Modified at: Thu Dec 2 13:51:54 1999 | ||
10 | * Modified by: Dag Brattli <dagb@cs.uit.no> | ||
11 | * | ||
12 | * Copyright (c) 1999 Dag Brattli, All Rights Reserved. | ||
13 | * | ||
14 | * This program is free software; you can redistribute it and/or | ||
15 | * modify it under the terms of the GNU General Public License as | ||
16 | * published by the Free Software Foundation; either version 2 of | ||
17 | * the License, or (at your option) any later version. | ||
18 | * | ||
19 | * This program is distributed in the hope that it will be useful, | ||
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
22 | * GNU General Public License for more details. | ||
23 | * | ||
24 | * You should have received a copy of the GNU General Public License | ||
25 | * along with this program; if not, write to the Free Software | ||
26 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, | ||
27 | * MA 02111-1307 USA | ||
28 | * | ||
29 | ********************************************************************/ | ||
30 | |||
31 | #ifndef IRDA_QOS_H | ||
32 | #define IRDA_QOS_H | ||
33 | |||
34 | #include <linux/config.h> | ||
35 | #include <linux/skbuff.h> | ||
36 | |||
37 | #include <net/irda/parameters.h> | ||
38 | |||
39 | #define PI_BAUD_RATE 0x01 | ||
40 | #define PI_MAX_TURN_TIME 0x82 | ||
41 | #define PI_DATA_SIZE 0x83 | ||
42 | #define PI_WINDOW_SIZE 0x84 | ||
43 | #define PI_ADD_BOFS 0x85 | ||
44 | #define PI_MIN_TURN_TIME 0x86 | ||
45 | #define PI_LINK_DISC 0x08 | ||
46 | |||
47 | #define IR_115200_MAX 0x3f | ||
48 | |||
49 | /* Baud rates (first byte) */ | ||
50 | #define IR_2400 0x01 | ||
51 | #define IR_9600 0x02 | ||
52 | #define IR_19200 0x04 | ||
53 | #define IR_38400 0x08 | ||
54 | #define IR_57600 0x10 | ||
55 | #define IR_115200 0x20 | ||
56 | #define IR_576000 0x40 | ||
57 | #define IR_1152000 0x80 | ||
58 | |||
59 | /* Baud rates (second byte) */ | ||
60 | #define IR_4000000 0x01 | ||
61 | #define IR_16000000 0x02 | ||
62 | |||
63 | /* Quality of Service information */ | ||
64 | typedef struct { | ||
65 | __u32 value; | ||
66 | __u16 bits; /* LSB is first byte, MSB is second byte */ | ||
67 | } qos_value_t; | ||
68 | |||
69 | struct qos_info { | ||
70 | magic_t magic; | ||
71 | |||
72 | qos_value_t baud_rate; /* IR_11520O | ... */ | ||
73 | qos_value_t max_turn_time; | ||
74 | qos_value_t data_size; | ||
75 | qos_value_t window_size; | ||
76 | qos_value_t additional_bofs; | ||
77 | qos_value_t min_turn_time; | ||
78 | qos_value_t link_disc_time; | ||
79 | |||
80 | qos_value_t power; | ||
81 | }; | ||
82 | |||
83 | extern int sysctl_max_baud_rate; | ||
84 | extern int sysctl_max_inactive_time; | ||
85 | |||
86 | void irda_init_max_qos_capabilies(struct qos_info *qos); | ||
87 | void irda_qos_compute_intersection(struct qos_info *, struct qos_info *); | ||
88 | |||
89 | __u32 irlap_max_line_capacity(__u32 speed, __u32 max_turn_time); | ||
90 | |||
91 | void irda_qos_bits_to_value(struct qos_info *qos); | ||
92 | |||
93 | /* So simple, how could we not inline those two ? | ||
94 | * Note : one byte is 10 bits if you include start and stop bits | ||
95 | * Jean II */ | ||
96 | #define irlap_min_turn_time_in_bytes(speed, min_turn_time) ( \ | ||
97 | speed * min_turn_time / 10000000 \ | ||
98 | ) | ||
99 | #define irlap_xbofs_in_usec(speed, xbofs) ( \ | ||
100 | xbofs * 10000000 / speed \ | ||
101 | ) | ||
102 | |||
103 | #endif | ||
104 | |||
diff --git a/include/net/irda/timer.h b/include/net/irda/timer.h new file mode 100644 index 000000000000..2c5d8864ab77 --- /dev/null +++ b/include/net/irda/timer.h | |||
@@ -0,0 +1,104 @@ | |||
1 | /********************************************************************* | ||
2 | * | ||
3 | * Filename: timer.h | ||
4 | * Version: | ||
5 | * Description: | ||
6 | * Status: Experimental. | ||
7 | * Author: Dag Brattli <dagb@cs.uit.no> | ||
8 | * Created at: Sat Aug 16 00:59:29 1997 | ||
9 | * Modified at: Thu Oct 7 12:25:24 1999 | ||
10 | * Modified by: Dag Brattli <dagb@cs.uit.no> | ||
11 | * | ||
12 | * Copyright (c) 1997, 1998-1999 Dag Brattli <dagb@cs.uit.no>, | ||
13 | * All Rights Reserved. | ||
14 | * Copyright (c) 2000-2002 Jean Tourrilhes <jt@hpl.hp.com> | ||
15 | * | ||
16 | * This program is free software; you can redistribute it and/or | ||
17 | * modify it under the terms of the GNU General Public License as | ||
18 | * published by the Free Software Foundation; either version 2 of | ||
19 | * the License, or (at your option) any later version. | ||
20 | * | ||
21 | * Neither Dag Brattli nor University of Tromsų admit liability nor | ||
22 | * provide warranty for any of this software. This material is | ||
23 | * provided "AS-IS" and at no charge. | ||
24 | * | ||
25 | ********************************************************************/ | ||
26 | |||
27 | #ifndef TIMER_H | ||
28 | #define TIMER_H | ||
29 | |||
30 | #include <linux/timer.h> | ||
31 | |||
32 | #include <asm/param.h> /* for HZ */ | ||
33 | |||
34 | #include <net/irda/irda.h> | ||
35 | |||
36 | /* A few forward declarations (to make compiler happy) */ | ||
37 | struct irlmp_cb; | ||
38 | struct irlap_cb; | ||
39 | struct lsap_cb; | ||
40 | struct lap_cb; | ||
41 | |||
42 | /* | ||
43 | * Timeout definitions, some defined in IrLAP 6.13.5 - p. 92 | ||
44 | */ | ||
45 | #define POLL_TIMEOUT (450*HZ/1000) /* Must never exceed 500 ms */ | ||
46 | #define FINAL_TIMEOUT (500*HZ/1000) /* Must never exceed 500 ms */ | ||
47 | |||
48 | /* | ||
49 | * Normally twice of p-timer. Note 3, IrLAP 6.3.11.2 - p. 60 suggests | ||
50 | * at least twice duration of the P-timer. | ||
51 | */ | ||
52 | #define WD_TIMEOUT (POLL_TIMEOUT*2) | ||
53 | |||
54 | #define MEDIABUSY_TIMEOUT (500*HZ/1000) /* 500 msec */ | ||
55 | #define SMALLBUSY_TIMEOUT (100*HZ/1000) /* 100 msec - IrLAP 6.13.4 */ | ||
56 | |||
57 | /* | ||
58 | * Slot timer must never exceed 85 ms, and must always be at least 25 ms, | ||
59 | * suggested to 75-85 msec by IrDA lite. This doesn't work with a lot of | ||
60 | * devices, and other stackes uses a lot more, so it's best we do it as well | ||
61 | * (Note : this is the default value and sysctl overides it - Jean II) | ||
62 | */ | ||
63 | #define SLOT_TIMEOUT (90*HZ/1000) | ||
64 | |||
65 | /* | ||
66 | * The latest discovery frame (XID) is longer due to the extra discovery | ||
67 | * information (hints, device name...). This is its extra length. | ||
68 | * We use that when setting the query timeout. Jean II | ||
69 | */ | ||
70 | #define XIDEXTRA_TIMEOUT (34*HZ/1000) /* 34 msec */ | ||
71 | |||
72 | #define WATCHDOG_TIMEOUT (20*HZ) /* 20 sec */ | ||
73 | |||
74 | typedef void (*TIMER_CALLBACK)(void *); | ||
75 | |||
76 | static inline void irda_start_timer(struct timer_list *ptimer, int timeout, | ||
77 | void* data, TIMER_CALLBACK callback) | ||
78 | { | ||
79 | ptimer->function = (void (*)(unsigned long)) callback; | ||
80 | ptimer->data = (unsigned long) data; | ||
81 | |||
82 | /* Set new value for timer (update or add timer). | ||
83 | * We use mod_timer() because it's more efficient and also | ||
84 | * safer with respect to race conditions - Jean II */ | ||
85 | mod_timer(ptimer, jiffies + timeout); | ||
86 | } | ||
87 | |||
88 | |||
89 | void irlap_start_slot_timer(struct irlap_cb *self, int timeout); | ||
90 | void irlap_start_query_timer(struct irlap_cb *self, int S, int s); | ||
91 | void irlap_start_final_timer(struct irlap_cb *self, int timeout); | ||
92 | void irlap_start_wd_timer(struct irlap_cb *self, int timeout); | ||
93 | void irlap_start_backoff_timer(struct irlap_cb *self, int timeout); | ||
94 | |||
95 | void irlap_start_mbusy_timer(struct irlap_cb *self, int timeout); | ||
96 | void irlap_stop_mbusy_timer(struct irlap_cb *); | ||
97 | |||
98 | void irlmp_start_watchdog_timer(struct lsap_cb *, int timeout); | ||
99 | void irlmp_start_discovery_timer(struct irlmp_cb *, int timeout); | ||
100 | void irlmp_start_idle_timer(struct lap_cb *, int timeout); | ||
101 | void irlmp_stop_idle_timer(struct lap_cb *self); | ||
102 | |||
103 | #endif | ||
104 | |||
diff --git a/include/net/irda/wrapper.h b/include/net/irda/wrapper.h new file mode 100644 index 000000000000..98768b3f9e31 --- /dev/null +++ b/include/net/irda/wrapper.h | |||
@@ -0,0 +1,58 @@ | |||
1 | /********************************************************************* | ||
2 | * | ||
3 | * Filename: wrapper.h | ||
4 | * Version: 1.2 | ||
5 | * Description: IrDA SIR async wrapper layer | ||
6 | * Status: Experimental. | ||
7 | * Author: Dag Brattli <dagb@cs.uit.no> | ||
8 | * Created at: Mon Aug 4 20:40:53 1997 | ||
9 | * Modified at: Tue Jan 11 12:37:29 2000 | ||
10 | * Modified by: Dag Brattli <dagb@cs.uit.no> | ||
11 | * | ||
12 | * Copyright (c) 1998-2000 Dag Brattli <dagb@cs.uit.no>, | ||
13 | * All Rights Reserved. | ||
14 | * | ||
15 | * This program is free software; you can redistribute it and/or | ||
16 | * modify it under the terms of the GNU General Public License as | ||
17 | * published by the Free Software Foundation; either version 2 of | ||
18 | * the License, or (at your option) any later version. | ||
19 | * | ||
20 | * Neither Dag Brattli nor University of Tromsų admit liability nor | ||
21 | * provide warranty for any of this software. This material is | ||
22 | * provided "AS-IS" and at no charge. | ||
23 | * | ||
24 | ********************************************************************/ | ||
25 | |||
26 | #ifndef WRAPPER_H | ||
27 | #define WRAPPER_H | ||
28 | |||
29 | #include <linux/types.h> | ||
30 | #include <linux/skbuff.h> | ||
31 | #include <linux/netdevice.h> | ||
32 | |||
33 | #include <net/irda/irda_device.h> /* iobuff_t */ | ||
34 | |||
35 | #define BOF 0xc0 /* Beginning of frame */ | ||
36 | #define XBOF 0xff | ||
37 | #define EOF 0xc1 /* End of frame */ | ||
38 | #define CE 0x7d /* Control escape */ | ||
39 | |||
40 | #define STA BOF /* Start flag */ | ||
41 | #define STO EOF /* End flag */ | ||
42 | |||
43 | #define IRDA_TRANS 0x20 /* Asynchronous transparency modifier */ | ||
44 | |||
45 | /* States for receving a frame in async mode */ | ||
46 | enum { | ||
47 | OUTSIDE_FRAME, | ||
48 | BEGIN_FRAME, | ||
49 | LINK_ESCAPE, | ||
50 | INSIDE_FRAME | ||
51 | }; | ||
52 | |||
53 | /* Proto definitions */ | ||
54 | int async_wrap_skb(struct sk_buff *skb, __u8 *tx_buff, int buffsize); | ||
55 | void async_unwrap_char(struct net_device *dev, struct net_device_stats *stats, | ||
56 | iobuff_t *buf, __u8 byte); | ||
57 | |||
58 | #endif | ||