ncp_fs_sb.h 4.5 KB

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