Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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> |
Ingo Molnar | 8e3f904 | 2006-03-23 03:00:43 -0800 | [diff] [blame] | 14 | #include <linux/mutex.h> |
Jens Axboe | f1970c7 | 2010-04-22 12:31:11 +0200 | [diff] [blame] | 15 | #include <linux/backing-dev.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | #include <linux/workqueue.h> |
| 17 | |
| 18 | #define NCP_DEFAULT_OPTIONS 0 /* 2 for packet signatures */ |
| 19 | |
| 20 | struct sock; |
| 21 | |
Al Viro | 32c419d | 2011-01-12 17:37:47 -0500 | [diff] [blame] | 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 |
Eric W. Biederman | 1ac7fd8 | 2012-02-07 16:28:28 -0800 | [diff] [blame] | 26 | kuid_t mounted_uid; /* Who may umount() this filesystem? */ |
Al Viro | 32c419d | 2011-01-12 17:37:47 -0500 | [diff] [blame] | 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]; |
Eric W. Biederman | 1ac7fd8 | 2012-02-07 16:28:28 -0800 | [diff] [blame] | 33 | kuid_t uid; |
| 34 | kgid_t gid; |
Al Viro | 1676765 | 2012-05-19 09:54:29 -0400 | [diff] [blame] | 35 | umode_t file_mode; |
| 36 | umode_t dir_mode; |
Al Viro | 32c419d | 2011-01-12 17:37:47 -0500 | [diff] [blame] | 37 | int info_fd; |
| 38 | }; |
| 39 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | struct ncp_server { |
| 41 | |
| 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 file *ncp_filp; /* File pointer to ncp socket */ |
| 49 | struct socket *ncp_sock;/* ncp socket */ |
| 50 | struct file *info_filp; |
| 51 | struct socket *info_sock; |
| 52 | |
| 53 | u8 sequence; |
| 54 | u8 task; |
| 55 | u16 connection; /* Remote connection number */ |
| 56 | |
| 57 | u8 completion; /* Status message from server */ |
| 58 | u8 conn_status; /* Bit 4 = 1 ==> Server going down, no |
| 59 | requests allowed anymore. |
| 60 | Bit 0 = 1 ==> Server is down. */ |
| 61 | |
| 62 | int buffer_size; /* Negotiated bufsize */ |
| 63 | |
| 64 | int reply_size; /* Size of last reply */ |
| 65 | |
| 66 | int packet_size; |
| 67 | unsigned char *packet; /* Here we prepare requests and |
| 68 | receive replies */ |
Pierre Ossman | c5f93cf | 2007-02-19 11:34:43 +0100 | [diff] [blame] | 69 | unsigned char *txbuf; /* Storage for current request */ |
| 70 | unsigned char *rxbuf; /* Storage for reply to current request */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | |
| 72 | int lock; /* To prevent mismatch in protocols. */ |
Ingo Molnar | 8e3f904 | 2006-03-23 03:00:43 -0800 | [diff] [blame] | 73 | struct mutex mutex; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | |
| 75 | int current_size; /* for packet preparation */ |
| 76 | int has_subfunction; |
| 77 | int ncp_reply_size; |
| 78 | |
| 79 | int root_setuped; |
Petr Vandrovec | 2e54eb9 | 2010-09-27 01:47:33 +0200 | [diff] [blame] | 80 | struct mutex root_setup_lock; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | |
| 82 | /* info for packet signing */ |
| 83 | int sign_wanted; /* 1=Server needs signed packets */ |
| 84 | int sign_active; /* 0=don't do signing, 1=do */ |
| 85 | char sign_root[8]; /* generated from password and encr. key */ |
| 86 | char sign_last[16]; |
| 87 | |
| 88 | /* Authentication info: NDS or BINDERY, username */ |
| 89 | struct { |
| 90 | int auth_type; |
| 91 | size_t object_name_len; |
| 92 | void* object_name; |
| 93 | int object_type; |
| 94 | } auth; |
| 95 | /* Password info */ |
| 96 | struct { |
| 97 | size_t len; |
| 98 | void* data; |
| 99 | } priv; |
Petr Vandrovec | 2e54eb9 | 2010-09-27 01:47:33 +0200 | [diff] [blame] | 100 | struct rw_semaphore auth_rwsem; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | |
| 102 | /* nls info: codepage for volume and charset for I/O */ |
| 103 | struct nls_table *nls_vol; |
| 104 | struct nls_table *nls_io; |
| 105 | |
| 106 | /* maximum age in jiffies */ |
Petr Vandrovec | 2e54eb9 | 2010-09-27 01:47:33 +0200 | [diff] [blame] | 107 | atomic_t dentry_ttl; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | |
| 109 | /* miscellaneous */ |
| 110 | unsigned int flags; |
| 111 | |
| 112 | spinlock_t requests_lock; /* Lock accesses to tx.requests, tx.creq and rcv.creq when STREAM mode */ |
| 113 | |
| 114 | void (*data_ready)(struct sock* sk, int len); |
| 115 | void (*error_report)(struct sock* sk); |
| 116 | void (*write_space)(struct sock* sk); /* STREAM mode only */ |
| 117 | struct { |
| 118 | struct work_struct tq; /* STREAM/DGRAM: data/error ready */ |
| 119 | struct ncp_request_reply* creq; /* STREAM/DGRAM: awaiting reply from this request */ |
Ingo Molnar | 8e3f904 | 2006-03-23 03:00:43 -0800 | [diff] [blame] | 120 | struct mutex creq_mutex; /* DGRAM only: lock accesses to rcv.creq */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 121 | |
| 122 | unsigned int state; /* STREAM only: receiver state */ |
| 123 | struct { |
Eric Dumazet | bc10502 | 2010-06-03 03:21:52 -0700 | [diff] [blame] | 124 | __u32 magic __packed; |
| 125 | __u32 len __packed; |
| 126 | __u16 type __packed; |
| 127 | __u16 p1 __packed; |
| 128 | __u16 p2 __packed; |
| 129 | __u16 p3 __packed; |
| 130 | __u16 type2 __packed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | } buf; /* STREAM only: temporary buffer */ |
| 132 | unsigned char* ptr; /* STREAM only: pointer to data */ |
| 133 | size_t len; /* STREAM only: length of data to receive */ |
| 134 | } rcv; |
| 135 | struct { |
| 136 | struct list_head requests; /* STREAM only: queued requests */ |
| 137 | struct work_struct tq; /* STREAM only: transmitter ready */ |
| 138 | struct ncp_request_reply* creq; /* STREAM only: currently transmitted entry */ |
| 139 | } tx; |
| 140 | struct timer_list timeout_tm; /* DGRAM only: timeout timer */ |
| 141 | struct work_struct timeout_tq; /* DGRAM only: associated queue, we run timers from process context */ |
| 142 | int timeout_last; /* DGRAM only: current timeout length */ |
| 143 | int timeout_retries; /* DGRAM only: retries left */ |
| 144 | struct { |
| 145 | size_t len; |
| 146 | __u8 data[128]; |
| 147 | } unexpected_packet; |
Jens Axboe | f1970c7 | 2010-04-22 12:31:11 +0200 | [diff] [blame] | 148 | struct backing_dev_info bdi; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 149 | }; |
| 150 | |
David Howells | c402895 | 2006-11-22 14:57:56 +0000 | [diff] [blame] | 151 | extern void ncp_tcp_rcv_proc(struct work_struct *work); |
| 152 | extern void ncp_tcp_tx_proc(struct work_struct *work); |
| 153 | extern void ncpdgram_rcv_proc(struct work_struct *work); |
| 154 | extern void ncpdgram_timeout_proc(struct work_struct *work); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 155 | extern void ncpdgram_timeout_call(unsigned long server); |
| 156 | extern void ncp_tcp_data_ready(struct sock* sk, int len); |
| 157 | extern void ncp_tcp_write_space(struct sock* sk); |
| 158 | extern void ncp_tcp_error_report(struct sock* sk); |
| 159 | |
| 160 | #define NCP_FLAG_UTF8 1 |
| 161 | |
| 162 | #define NCP_CLR_FLAG(server, flag) ((server)->flags &= ~(flag)) |
| 163 | #define NCP_SET_FLAG(server, flag) ((server)->flags |= (flag)) |
| 164 | #define NCP_IS_FLAG(server, flag) ((server)->flags & (flag)) |
| 165 | |
| 166 | static inline int ncp_conn_valid(struct ncp_server *server) |
| 167 | { |
| 168 | return ((server->conn_status & 0x11) == 0); |
| 169 | } |
| 170 | |
| 171 | static inline void ncp_invalidate_conn(struct ncp_server *server) |
| 172 | { |
| 173 | server->conn_status |= 0x01; |
| 174 | } |
| 175 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 176 | #endif |