ncp_fs_sb.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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 socket *ncp_sock;/* ncp socket */
  41. struct socket *info_sock;
  42. u8 sequence;
  43. u8 task;
  44. u16 connection; /* Remote connection number */
  45. u8 completion; /* Status message from server */
  46. u8 conn_status; /* Bit 4 = 1 ==> Server going down, no
  47. requests allowed anymore.
  48. Bit 0 = 1 ==> Server is down. */
  49. int buffer_size; /* Negotiated bufsize */
  50. int reply_size; /* Size of last reply */
  51. int packet_size;
  52. unsigned char *packet; /* Here we prepare requests and
  53. receive replies */
  54. unsigned char *txbuf; /* Storage for current request */
  55. unsigned char *rxbuf; /* Storage for reply to current request */
  56. int lock; /* To prevent mismatch in protocols. */
  57. struct mutex mutex;
  58. int current_size; /* for packet preparation */
  59. int has_subfunction;
  60. int ncp_reply_size;
  61. int root_setuped;
  62. struct mutex root_setup_lock;
  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. /* Authentication info: NDS or BINDERY, username */
  69. struct {
  70. int auth_type;
  71. size_t object_name_len;
  72. void* object_name;
  73. int object_type;
  74. } auth;
  75. /* Password info */
  76. struct {
  77. size_t len;
  78. void* data;
  79. } priv;
  80. struct rw_semaphore auth_rwsem;
  81. /* nls info: codepage for volume and charset for I/O */
  82. struct nls_table *nls_vol;
  83. struct nls_table *nls_io;
  84. /* maximum age in jiffies */
  85. atomic_t dentry_ttl;
  86. /* miscellaneous */
  87. unsigned int flags;
  88. spinlock_t requests_lock; /* Lock accesses to tx.requests, tx.creq and rcv.creq when STREAM mode */
  89. void (*data_ready)(struct sock* sk);
  90. void (*error_report)(struct sock* sk);
  91. void (*write_space)(struct sock* sk); /* STREAM mode only */
  92. struct {
  93. struct work_struct tq; /* STREAM/DGRAM: data/error ready */
  94. struct ncp_request_reply* creq; /* STREAM/DGRAM: awaiting reply from this request */
  95. struct mutex creq_mutex; /* DGRAM only: lock accesses to rcv.creq */
  96. unsigned int state; /* STREAM only: receiver state */
  97. struct {
  98. __u32 magic __packed;
  99. __u32 len __packed;
  100. __u16 type __packed;
  101. __u16 p1 __packed;
  102. __u16 p2 __packed;
  103. __u16 p3 __packed;
  104. __u16 type2 __packed;
  105. } buf; /* STREAM only: temporary buffer */
  106. unsigned char* ptr; /* STREAM only: pointer to data */
  107. size_t len; /* STREAM only: length of data to receive */
  108. } rcv;
  109. struct {
  110. struct list_head requests; /* STREAM only: queued requests */
  111. struct work_struct tq; /* STREAM only: transmitter ready */
  112. struct ncp_request_reply* creq; /* STREAM only: currently transmitted entry */
  113. } tx;
  114. struct timer_list timeout_tm; /* DGRAM only: timeout timer */
  115. struct work_struct timeout_tq; /* DGRAM only: associated queue, we run timers from process context */
  116. int timeout_last; /* DGRAM only: current timeout length */
  117. int timeout_retries; /* DGRAM only: retries left */
  118. struct {
  119. size_t len;
  120. __u8 data[128];
  121. } unexpected_packet;
  122. struct backing_dev_info bdi;
  123. };
  124. extern void ncp_tcp_rcv_proc(struct work_struct *work);
  125. extern void ncp_tcp_tx_proc(struct work_struct *work);
  126. extern void ncpdgram_rcv_proc(struct work_struct *work);
  127. extern void ncpdgram_timeout_proc(struct work_struct *work);
  128. extern void ncpdgram_timeout_call(unsigned long server);
  129. extern void ncp_tcp_data_ready(struct sock* sk);
  130. extern void ncp_tcp_write_space(struct sock* sk);
  131. extern void ncp_tcp_error_report(struct sock* sk);
  132. #define NCP_FLAG_UTF8 1
  133. #define NCP_CLR_FLAG(server, flag) ((server)->flags &= ~(flag))
  134. #define NCP_SET_FLAG(server, flag) ((server)->flags |= (flag))
  135. #define NCP_IS_FLAG(server, flag) ((server)->flags & (flag))
  136. static inline int ncp_conn_valid(struct ncp_server *server)
  137. {
  138. return ((server->conn_status & 0x11) == 0);
  139. }
  140. static inline void ncp_invalidate_conn(struct ncp_server *server)
  141. {
  142. server->conn_status |= 0x01;
  143. }
  144. #endif