ncp_fs_sb.h 4.4 KB

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