ncp_fs_sb.h 5.1 KB

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