ncp_fs_sb.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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. int lock; /* To prevent mismatch in protocols. */
  39. struct mutex mutex;
  40. int current_size; /* for packet preparation */
  41. int has_subfunction;
  42. int ncp_reply_size;
  43. int root_setuped;
  44. /* info for packet signing */
  45. int sign_wanted; /* 1=Server needs signed packets */
  46. int sign_active; /* 0=don't do signing, 1=do */
  47. char sign_root[8]; /* generated from password and encr. key */
  48. char sign_last[16];
  49. /* Authentication info: NDS or BINDERY, username */
  50. struct {
  51. int auth_type;
  52. size_t object_name_len;
  53. void* object_name;
  54. int object_type;
  55. } auth;
  56. /* Password info */
  57. struct {
  58. size_t len;
  59. void* data;
  60. } priv;
  61. /* nls info: codepage for volume and charset for I/O */
  62. struct nls_table *nls_vol;
  63. struct nls_table *nls_io;
  64. /* maximum age in jiffies */
  65. int dentry_ttl;
  66. /* miscellaneous */
  67. unsigned int flags;
  68. spinlock_t requests_lock; /* Lock accesses to tx.requests, tx.creq and rcv.creq when STREAM mode */
  69. void (*data_ready)(struct sock* sk, int len);
  70. void (*error_report)(struct sock* sk);
  71. void (*write_space)(struct sock* sk); /* STREAM mode only */
  72. struct {
  73. struct work_struct tq; /* STREAM/DGRAM: data/error ready */
  74. struct ncp_request_reply* creq; /* STREAM/DGRAM: awaiting reply from this request */
  75. struct mutex creq_mutex; /* DGRAM only: lock accesses to rcv.creq */
  76. unsigned int state; /* STREAM only: receiver state */
  77. struct {
  78. __u32 magic __attribute__((packed));
  79. __u32 len __attribute__((packed));
  80. __u16 type __attribute__((packed));
  81. __u16 p1 __attribute__((packed));
  82. __u16 p2 __attribute__((packed));
  83. __u16 p3 __attribute__((packed));
  84. __u16 type2 __attribute__((packed));
  85. } buf; /* STREAM only: temporary buffer */
  86. unsigned char* ptr; /* STREAM only: pointer to data */
  87. size_t len; /* STREAM only: length of data to receive */
  88. } rcv;
  89. struct {
  90. struct list_head requests; /* STREAM only: queued requests */
  91. struct work_struct tq; /* STREAM only: transmitter ready */
  92. struct ncp_request_reply* creq; /* STREAM only: currently transmitted entry */
  93. } tx;
  94. struct timer_list timeout_tm; /* DGRAM only: timeout timer */
  95. struct work_struct timeout_tq; /* DGRAM only: associated queue, we run timers from process context */
  96. int timeout_last; /* DGRAM only: current timeout length */
  97. int timeout_retries; /* DGRAM only: retries left */
  98. struct {
  99. size_t len;
  100. __u8 data[128];
  101. } unexpected_packet;
  102. };
  103. extern void ncp_tcp_rcv_proc(void *server);
  104. extern void ncp_tcp_tx_proc(void *server);
  105. extern void ncpdgram_rcv_proc(void *server);
  106. extern void ncpdgram_timeout_proc(void *server);
  107. extern void ncpdgram_timeout_call(unsigned long server);
  108. extern void ncp_tcp_data_ready(struct sock* sk, int len);
  109. extern void ncp_tcp_write_space(struct sock* sk);
  110. extern void ncp_tcp_error_report(struct sock* sk);
  111. #define NCP_FLAG_UTF8 1
  112. #define NCP_CLR_FLAG(server, flag) ((server)->flags &= ~(flag))
  113. #define NCP_SET_FLAG(server, flag) ((server)->flags |= (flag))
  114. #define NCP_IS_FLAG(server, flag) ((server)->flags & (flag))
  115. static inline int ncp_conn_valid(struct ncp_server *server)
  116. {
  117. return ((server->conn_status & 0x11) == 0);
  118. }
  119. static inline void ncp_invalidate_conn(struct ncp_server *server)
  120. {
  121. server->conn_status |= 0x01;
  122. }
  123. #endif /* __KERNEL__ */
  124. #endif