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