blob: 5ec9ca671687e7c174b76b83995f209c0b0eacba [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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 Molnar8e3f9042006-03-23 03:00:43 -080014#include <linux/mutex.h>
Jens Axboef1970c72010-04-22 12:31:11 +020015#include <linux/backing-dev.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070016
17#ifdef __KERNEL__
18
19#include <linux/workqueue.h>
20
21#define NCP_DEFAULT_OPTIONS 0 /* 2 for packet signatures */
22
23struct sock;
24
25struct 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 Ossmanc5f93cf2007-02-19 11:34:43 +010054 unsigned char *txbuf; /* Storage for current request */
55 unsigned char *rxbuf; /* Storage for reply to current request */
Linus Torvalds1da177e2005-04-16 15:20:36 -070056
57 int lock; /* To prevent mismatch in protocols. */
Ingo Molnar8e3f9042006-03-23 03:00:43 -080058 struct mutex mutex;
Linus Torvalds1da177e2005-04-16 15:20:36 -070059
60 int current_size; /* for packet preparation */
61 int has_subfunction;
62 int ncp_reply_size;
63
64 int root_setuped;
65
66 /* info for packet signing */
67 int sign_wanted; /* 1=Server needs signed packets */
68 int sign_active; /* 0=don't do signing, 1=do */
69 char sign_root[8]; /* generated from password and encr. key */
70 char sign_last[16];
71
72 /* Authentication info: NDS or BINDERY, username */
73 struct {
74 int auth_type;
75 size_t object_name_len;
76 void* object_name;
77 int object_type;
78 } auth;
79 /* Password info */
80 struct {
81 size_t len;
82 void* data;
83 } priv;
84
85 /* nls info: codepage for volume and charset for I/O */
86 struct nls_table *nls_vol;
87 struct nls_table *nls_io;
88
89 /* maximum age in jiffies */
90 int dentry_ttl;
91
92 /* miscellaneous */
93 unsigned int flags;
94
95 spinlock_t requests_lock; /* Lock accesses to tx.requests, tx.creq and rcv.creq when STREAM mode */
96
97 void (*data_ready)(struct sock* sk, int len);
98 void (*error_report)(struct sock* sk);
99 void (*write_space)(struct sock* sk); /* STREAM mode only */
100 struct {
101 struct work_struct tq; /* STREAM/DGRAM: data/error ready */
102 struct ncp_request_reply* creq; /* STREAM/DGRAM: awaiting reply from this request */
Ingo Molnar8e3f9042006-03-23 03:00:43 -0800103 struct mutex creq_mutex; /* DGRAM only: lock accesses to rcv.creq */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104
105 unsigned int state; /* STREAM only: receiver state */
106 struct {
107 __u32 magic __attribute__((packed));
108 __u32 len __attribute__((packed));
109 __u16 type __attribute__((packed));
110 __u16 p1 __attribute__((packed));
111 __u16 p2 __attribute__((packed));
112 __u16 p3 __attribute__((packed));
113 __u16 type2 __attribute__((packed));
114 } buf; /* STREAM only: temporary buffer */
115 unsigned char* ptr; /* STREAM only: pointer to data */
116 size_t len; /* STREAM only: length of data to receive */
117 } rcv;
118 struct {
119 struct list_head requests; /* STREAM only: queued requests */
120 struct work_struct tq; /* STREAM only: transmitter ready */
121 struct ncp_request_reply* creq; /* STREAM only: currently transmitted entry */
122 } tx;
123 struct timer_list timeout_tm; /* DGRAM only: timeout timer */
124 struct work_struct timeout_tq; /* DGRAM only: associated queue, we run timers from process context */
125 int timeout_last; /* DGRAM only: current timeout length */
126 int timeout_retries; /* DGRAM only: retries left */
127 struct {
128 size_t len;
129 __u8 data[128];
130 } unexpected_packet;
Jens Axboef1970c72010-04-22 12:31:11 +0200131 struct backing_dev_info bdi;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132};
133
David Howellsc4028952006-11-22 14:57:56 +0000134extern void ncp_tcp_rcv_proc(struct work_struct *work);
135extern void ncp_tcp_tx_proc(struct work_struct *work);
136extern void ncpdgram_rcv_proc(struct work_struct *work);
137extern void ncpdgram_timeout_proc(struct work_struct *work);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138extern void ncpdgram_timeout_call(unsigned long server);
139extern void ncp_tcp_data_ready(struct sock* sk, int len);
140extern void ncp_tcp_write_space(struct sock* sk);
141extern void ncp_tcp_error_report(struct sock* sk);
142
143#define NCP_FLAG_UTF8 1
144
145#define NCP_CLR_FLAG(server, flag) ((server)->flags &= ~(flag))
146#define NCP_SET_FLAG(server, flag) ((server)->flags |= (flag))
147#define NCP_IS_FLAG(server, flag) ((server)->flags & (flag))
148
149static inline int ncp_conn_valid(struct ncp_server *server)
150{
151 return ((server->conn_status & 0x11) == 0);
152}
153
154static inline void ncp_invalidate_conn(struct ncp_server *server)
155{
156 server->conn_status |= 0x01;
157}
158
159#endif /* __KERNEL__ */
160
161#endif
162