import of upstream 2.4.34.4 from kernel.org
[linux-2.4.git] / net / irda / irnet / irnet_irda.h
1 /*
2  *      IrNET protocol module : Synchronous PPP over an IrDA socket.
3  *
4  *              Jean II - HPL `00 - <jt@hpl.hp.com>
5  *
6  * This file contains all definitions and declarations necessary for the
7  * IRDA part of the IrNET module (dealing with IrTTP, IrIAS and co).
8  * This file is a private header, so other modules don't want to know
9  * what's in there...
10  */
11
12 #ifndef IRNET_IRDA_H
13 #define IRNET_IRDA_H
14
15 /***************************** INCLUDES *****************************/
16 /* Please add other headers in irnet.h */
17
18 #include "irnet.h"              /* Module global include */
19
20 /************************ CONSTANTS & MACROS ************************/
21
22 /*
23  * Name of the service (socket name) used by IrNET
24  */
25 /* IAS object name (or part of it) */
26 #define IRNET_SERVICE_NAME      "IrNetv1"
27 /* IAS attribute */
28 #define IRNET_IAS_VALUE         "IrDA:TinyTP:LsapSel"
29 /* LMP notify name for client (only for /proc/net/irda/irlmp) */
30 #define IRNET_NOTIFY_NAME       "IrNET socket"
31 /* LMP notify name for server (only for /proc/net/irda/irlmp) */
32 #define IRNET_NOTIFY_NAME_SERV  "IrNET server"
33
34 /****************************** TYPES ******************************/
35
36 /*
37  * This is the main structure where we store all the data pertaining to
38  * the IrNET server (listen for connection requests) and the root
39  * of the IrNET socket list
40  */
41 typedef struct irnet_root
42 {
43   irnet_socket          s;              /* To pretend we are a client... */
44
45   /* Generic stuff */
46   int                   magic;          /* Paranoia */
47   int                   running;        /* Are we operational ? */
48
49   /* Link list of all IrNET instances opened */
50   hashbin_t *           list;
51   spinlock_t            spinlock;       /* Serialize access to the list */
52   /* Note : the way hashbin has been designed is absolutely not
53    * reentrant, beware... So, we blindly protect all with spinlock */
54
55   /* Handle for the hint bit advertised in IrLMP */
56   __u32                 skey;
57
58   /* Server socket part */
59   struct ias_object *   ias_obj;        /* Our service name + lsap in IAS */
60
61 } irnet_root;
62
63
64 /**************************** PROTOTYPES ****************************/
65
66 /* ----------------------- CONTROL CHANNEL ----------------------- */
67 static void
68         irnet_post_event(irnet_socket *,
69                          irnet_event,
70                          __u32,
71                          __u32,
72                          char *);
73 /* ----------------------- IRDA SUBROUTINES ----------------------- */
74 static inline int
75         irnet_open_tsap(irnet_socket *);
76 static inline __u8
77         irnet_ias_to_tsap(irnet_socket *,
78                           int,
79                           struct ias_value *);
80 static inline int
81         irnet_find_lsap_sel(irnet_socket *);
82 static inline int
83         irnet_connect_tsap(irnet_socket *);
84 static inline int
85         irnet_discover_next_daddr(irnet_socket *);
86 static inline int
87         irnet_discover_daddr_and_lsap_sel(irnet_socket *);
88 static inline int
89         irnet_dname_to_daddr(irnet_socket *);
90 /* ------------------------ SERVER SOCKET ------------------------ */
91 static inline int
92         irnet_daddr_to_dname(irnet_socket *);
93 static inline irnet_socket *
94         irnet_find_socket(irnet_socket *);
95 static inline int
96         irnet_connect_socket(irnet_socket *,
97                              irnet_socket *,
98                              struct qos_info *,
99                              __u32,
100                              __u8);
101 static inline void
102         irnet_disconnect_server(irnet_socket *,
103                                 struct sk_buff *);
104 static inline int
105         irnet_setup_server(void);
106 static inline void
107         irnet_destroy_server(void);
108 /* ---------------------- IRDA-TTP CALLBACKS ---------------------- */
109 static int
110         irnet_data_indication(void *,           /* instance */
111                               void *,           /* sap */
112                               struct sk_buff *);
113 static void
114         irnet_disconnect_indication(void *,
115                                     void *,
116                                     LM_REASON,
117                                     struct sk_buff *);
118 static void
119         irnet_connect_confirm(void *,
120                               void *,
121                               struct qos_info *,
122                               __u32,
123                               __u8,
124                               struct sk_buff *);
125 static void
126         irnet_flow_indication(void *,
127                               void *,
128                               LOCAL_FLOW);
129 static void
130         irnet_status_indication(void *,
131                                 LINK_STATUS,
132                                 LOCK_STATUS);
133 static void
134         irnet_connect_indication(void *,
135                                  void *,
136                                  struct qos_info *,
137                                  __u32,
138                                  __u8,
139                                  struct sk_buff *);
140 /* -------------------- IRDA-IAS/LMP CALLBACKS -------------------- */
141 static void
142         irnet_getvalue_confirm(int,
143                                __u16,
144                                struct ias_value *,
145                                void *);
146 static void
147         irnet_discovervalue_confirm(int,
148                                     __u16, 
149                                     struct ias_value *,
150                                     void *);
151 #ifdef DISCOVERY_EVENTS
152 static void
153         irnet_discovery_indication(discovery_t *,
154                                    DISCOVERY_MODE,
155                                    void *);
156 static void
157         irnet_expiry_indication(discovery_t *,
158                                 DISCOVERY_MODE,
159                                 void *);
160 #endif
161 /* -------------------------- PROC ENTRY -------------------------- */
162 #ifdef CONFIG_PROC_FS
163 static int
164         irnet_proc_read(char *,
165                         char **,
166                         off_t,
167                         int);
168 #endif /* CONFIG_PROC_FS */
169
170 /**************************** VARIABLES ****************************/
171
172 /*
173  * The IrNET server. Listen to connection requests and co...
174  */
175 static struct irnet_root        irnet_server;
176
177 /* Control channel stuff (note : extern) */
178 struct irnet_ctrl_channel       irnet_events;
179
180 /* The /proc/net/irda directory, defined elsewhere... */
181 #ifdef CONFIG_PROC_FS
182 extern struct proc_dir_entry *proc_irda;
183 #endif /* CONFIG_PROC_FS */
184
185 #endif /* IRNET_IRDA_H */