Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
[linux.git] / fs / ncpfs / ncp_fs_sb.h
1 /*
2  *  ncp_fs_sb.h
3  *
4  *  Copyright (C) 1995, 1996 by Volker Lendecke
5  *
6  */
7
8 #ifndef _NCP_FS_SB
9 #define _NCP_FS_SB
10
11 #include <linux/types.h>
12 #include <linux/ncp_mount.h>
13 #include <linux/net.h>
14 #include <linux/mutex.h>
15 #include <linux/backing-dev.h>
16 #include <linux/workqueue.h>
17
18 #define NCP_DEFAULT_OPTIONS 0           /* 2 for packet signatures */
19
20 struct sock;
21
22 struct ncp_mount_data_kernel {
23         unsigned long    flags;         /* NCP_MOUNT_* flags */
24         unsigned int     int_flags;     /* internal flags */
25 #define NCP_IMOUNT_LOGGEDIN_POSSIBLE    0x0001
26         kuid_t           mounted_uid;   /* Who may umount() this filesystem? */
27         struct pid      *wdog_pid;      /* Who cares for our watchdog packets? */
28         unsigned int     ncp_fd;        /* The socket to the ncp port */
29         unsigned int     time_out;      /* How long should I wait after
30                                            sending a NCP request? */
31         unsigned int     retry_count;   /* And how often should I retry? */
32         unsigned char    mounted_vol[NCP_VOLNAME_LEN + 1];
33         kuid_t           uid;
34         kgid_t           gid;
35         umode_t          file_mode;
36         umode_t          dir_mode;
37         int              info_fd;
38 };
39
40 struct ncp_server {
41         struct rcu_head rcu;
42         struct ncp_mount_data_kernel m; /* Nearly all of the mount data is of
43                                            interest for us later, so we store
44                                            it completely. */
45
46         __u8 name_space[NCP_NUMBER_OF_VOLUMES + 2];
47
48         struct socket *ncp_sock;/* ncp socket */
49         struct socket *info_sock;
50
51         u8 sequence;
52         u8 task;
53         u16 connection;         /* Remote connection number */
54
55         u8 completion;          /* Status message from server */
56         u8 conn_status;         /* Bit 4 = 1 ==> Server going down, no
57                                    requests allowed anymore.
58                                    Bit 0 = 1 ==> Server is down. */
59
60         int buffer_size;        /* Negotiated bufsize */
61
62         int reply_size;         /* Size of last reply */
63
64         int packet_size;
65         unsigned char *packet;  /* Here we prepare requests and
66                                    receive replies */
67         unsigned char *txbuf;   /* Storage for current request */
68         unsigned char *rxbuf;   /* Storage for reply to current request */
69
70         int lock;               /* To prevent mismatch in protocols. */
71         struct mutex mutex;
72
73         int current_size;       /* for packet preparation */
74         int has_subfunction;
75         int ncp_reply_size;
76
77         int root_setuped;
78         struct mutex root_setup_lock;
79
80         /* info for packet signing */
81         int sign_wanted;        /* 1=Server needs signed packets */
82         int sign_active;        /* 0=don't do signing, 1=do */
83         char sign_root[8];      /* generated from password and encr. key */
84         char sign_last[16];     
85
86         /* Authentication info: NDS or BINDERY, username */
87         struct {
88                 int     auth_type;
89                 size_t  object_name_len;
90                 void*   object_name;
91                 int     object_type;
92         } auth;
93         /* Password info */
94         struct {
95                 size_t  len;
96                 void*   data;
97         } priv;
98         struct rw_semaphore auth_rwsem;
99
100         /* nls info: codepage for volume and charset for I/O */
101         struct nls_table *nls_vol;
102         struct nls_table *nls_io;
103
104         /* maximum age in jiffies */
105         atomic_t dentry_ttl;
106
107         /* miscellaneous */
108         unsigned int flags;
109
110         spinlock_t requests_lock;       /* Lock accesses to tx.requests, tx.creq and rcv.creq when STREAM mode */
111
112         void (*data_ready)(struct sock* sk);
113         void (*error_report)(struct sock* sk);
114         void (*write_space)(struct sock* sk);   /* STREAM mode only */
115         struct {
116                 struct work_struct tq;          /* STREAM/DGRAM: data/error ready */
117                 struct ncp_request_reply* creq; /* STREAM/DGRAM: awaiting reply from this request */
118                 struct mutex creq_mutex;        /* DGRAM only: lock accesses to rcv.creq */
119
120                 unsigned int state;             /* STREAM only: receiver state */
121                 struct {
122                         __u32 magic __packed;
123                         __u32 len __packed;
124                         __u16 type __packed;
125                         __u16 p1 __packed;
126                         __u16 p2 __packed;
127                         __u16 p3 __packed;
128                         __u16 type2 __packed;
129                 } buf;                          /* STREAM only: temporary buffer */
130                 unsigned char* ptr;             /* STREAM only: pointer to data */
131                 size_t len;                     /* STREAM only: length of data to receive */
132         } rcv;
133         struct {
134                 struct list_head requests;      /* STREAM only: queued requests */
135                 struct work_struct tq;          /* STREAM only: transmitter ready */
136                 struct ncp_request_reply* creq; /* STREAM only: currently transmitted entry */
137         } tx;
138         struct timer_list timeout_tm;           /* DGRAM only: timeout timer */
139         struct work_struct timeout_tq;          /* DGRAM only: associated queue, we run timers from process context */
140         int timeout_last;                       /* DGRAM only: current timeout length */
141         int timeout_retries;                    /* DGRAM only: retries left */
142         struct {
143                 size_t len;
144                 __u8 data[128];
145         } unexpected_packet;
146         struct backing_dev_info bdi;
147 };
148
149 extern void ncp_tcp_rcv_proc(struct work_struct *work);
150 extern void ncp_tcp_tx_proc(struct work_struct *work);
151 extern void ncpdgram_rcv_proc(struct work_struct *work);
152 extern void ncpdgram_timeout_proc(struct work_struct *work);
153 extern void ncpdgram_timeout_call(unsigned long server);
154 extern void ncp_tcp_data_ready(struct sock* sk);
155 extern void ncp_tcp_write_space(struct sock* sk);
156 extern void ncp_tcp_error_report(struct sock* sk);
157
158 #define NCP_FLAG_UTF8   1
159
160 #define NCP_CLR_FLAG(server, flag)      ((server)->flags &= ~(flag))
161 #define NCP_SET_FLAG(server, flag)      ((server)->flags |= (flag))
162 #define NCP_IS_FLAG(server, flag)       ((server)->flags & (flag))
163
164 static inline int ncp_conn_valid(struct ncp_server *server)
165 {
166         return ((server->conn_status & 0x11) == 0);
167 }
168
169 static inline void ncp_invalidate_conn(struct ncp_server *server)
170 {
171         server->conn_status |= 0x01;
172 }
173
174 #endif