ncp_fs_sb.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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. __kernel_uid32_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. __kernel_uid32_t uid;
  29. __kernel_gid32_t gid;
  30. __kernel_mode_t file_mode;
  31. __kernel_mode_t dir_mode;
  32. int info_fd;
  33. };
  34. struct ncp_server {
  35. struct ncp_mount_data_kernel m; /* Nearly all of the mount data is of
  36. interest for us later, so we store
  37. it completely. */
  38. __u8 name_space[NCP_NUMBER_OF_VOLUMES + 2];
  39. struct file *ncp_filp; /* File pointer to ncp socket */
  40. struct socket *ncp_sock;/* ncp socket */
  41. struct file *info_filp;
  42. struct socket *info_sock;
  43. u8 sequence;
  44. u8 task;
  45. u16 connection; /* Remote connection number */
  46. u8 completion; /* Status message from server */
  47. u8 conn_status; /* Bit 4 = 1 ==> Server going down, no
  48. requests allowed anymore.
  49. Bit 0 = 1 ==> Server is down. */
  50. int buffer_size; /* Negotiated bufsize */
  51. int reply_size; /* Size of last reply */
  52. int packet_size;
  53. unsigned char *packet; /* Here we prepare requests and
  54. receive replies */
  55. unsigned char *txbuf; /* Storage for current request */
  56. unsigned char *rxbuf; /* Storage for reply to current request */
  57. int lock; /* To prevent mismatch in protocols. */
  58. struct mutex mutex;
  59. int current_size; /* for packet preparation */
  60. int has_subfunction;
  61. int ncp_reply_size;
  62. int root_setuped;
  63. struct mutex root_setup_lock;
  64. /* info for packet signing */
  65. int sign_wanted; /* 1=Server needs signed packets */
  66. int sign_active; /* 0=don't do signing, 1=do */
  67. char sign_root[8]; /* generated from password and encr. key */
  68. char sign_last[16];
  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. struct rw_semaphore auth_rwsem;
  82. /* nls info: codepage for volume and charset for I/O */
  83. struct nls_table *nls_vol;
  84. struct nls_table *nls_io;
  85. /* maximum age in jiffies */
  86. atomic_t dentry_ttl;
  87. /* miscellaneous */
  88. unsigned int flags;
  89. spinlock_t requests_lock; /* Lock accesses to tx.requests, tx.creq and rcv.creq when STREAM mode */
  90. void (*data_ready)(struct sock* sk, int len);
  91. void (*error_report)(struct sock* sk);
  92. void (*write_space)(struct sock* sk); /* STREAM mode only */
  93. struct {
  94. struct work_struct tq; /* STREAM/DGRAM: data/error ready */
  95. struct ncp_request_reply* creq; /* STREAM/DGRAM: awaiting reply from this request */
  96. struct mutex creq_mutex; /* DGRAM only: lock accesses to rcv.creq */
  97. unsigned int state; /* STREAM only: receiver state */
  98. struct {
  99. __u32 magic __packed;
  100. __u32 len __packed;
  101. __u16 type __packed;
  102. __u16 p1 __packed;
  103. __u16 p2 __packed;
  104. __u16 p3 __packed;
  105. __u16 type2 __packed;
  106. } buf; /* STREAM only: temporary buffer */
  107. unsigned char* ptr; /* STREAM only: pointer to data */
  108. size_t len; /* STREAM only: length of data to receive */
  109. } rcv;
  110. struct {
  111. struct list_head requests; /* STREAM only: queued requests */
  112. struct work_struct tq; /* STREAM only: transmitter ready */
  113. struct ncp_request_reply* creq; /* STREAM only: currently transmitted entry */
  114. } tx;
  115. struct timer_list timeout_tm; /* DGRAM only: timeout timer */
  116. struct work_struct timeout_tq; /* DGRAM only: associated queue, we run timers from process context */
  117. int timeout_last; /* DGRAM only: current timeout length */
  118. int timeout_retries; /* DGRAM only: retries left */
  119. struct {
  120. size_t len;
  121. __u8 data[128];
  122. } unexpected_packet;
  123. struct backing_dev_info bdi;
  124. };
  125. extern void ncp_tcp_rcv_proc(struct work_struct *work);
  126. extern void ncp_tcp_tx_proc(struct work_struct *work);
  127. extern void ncpdgram_rcv_proc(struct work_struct *work);
  128. extern void ncpdgram_timeout_proc(struct work_struct *work);
  129. extern void ncpdgram_timeout_call(unsigned long server);
  130. extern void ncp_tcp_data_ready(struct sock* sk, int len);
  131. extern void ncp_tcp_write_space(struct sock* sk);
  132. extern void ncp_tcp_error_report(struct sock* sk);
  133. #define NCP_FLAG_UTF8 1
  134. #define NCP_CLR_FLAG(server, flag) ((server)->flags &= ~(flag))
  135. #define NCP_SET_FLAG(server, flag) ((server)->flags |= (flag))
  136. #define NCP_IS_FLAG(server, flag) ((server)->flags & (flag))
  137. static inline int ncp_conn_valid(struct ncp_server *server)
  138. {
  139. return ((server->conn_status & 0x11) == 0);
  140. }
  141. static inline void ncp_invalidate_conn(struct ncp_server *server)
  142. {
  143. server->conn_status |= 0x01;
  144. }
  145. #endif