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