smb_rq.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /*-
  2. * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
  3. *
  4. * Copyright (c) 2000-2001 Boris Popov
  5. * All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions
  9. * are met:
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  17. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  18. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  19. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  20. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  21. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  22. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  23. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  24. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  25. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  26. * SUCH DAMAGE.
  27. *
  28. * $FreeBSD$
  29. */
  30. #ifndef _NETSMB_SMB_RQ_H_
  31. #define _NETSMB_SMB_RQ_H_
  32. #ifndef MB_MSYSTEM
  33. #include <sys/mchain.h>
  34. #endif
  35. #define SMBR_ALLOCED 0x0001 /* structure was malloced */
  36. #define SMBR_SENT 0x0002 /* request successfully transmitted */
  37. #define SMBR_REXMIT 0x0004 /* request should be retransmitted */
  38. #define SMBR_INTR 0x0008 /* request interrupted */
  39. #define SMBR_RESTART 0x0010 /* request should be repeated if possible */
  40. #define SMBR_NORESTART 0x0020 /* request is not restartable */
  41. #define SMBR_MULTIPACKET 0x0040 /* multiple packets can be sent and received */
  42. #define SMBR_INTERNAL 0x0080 /* request is internal to smbrqd */
  43. #define SMBR_XLOCK 0x0100 /* request locked and can't be moved */
  44. #define SMBR_XLOCKWANT 0x0200 /* waiter on XLOCK */
  45. #define SMBT2_ALLSENT 0x0001 /* all data and params are sent */
  46. #define SMBT2_ALLRECV 0x0002 /* all data and params are received */
  47. #define SMBT2_ALLOCED 0x0004
  48. #define SMBT2_RESTART 0x0008
  49. #define SMBT2_NORESTART 0x0010
  50. #define SMBT2_SECONDARY 0x0020 /* secondary request */
  51. #define SMBRQ_SLOCK(rqp) smb_sl_lock(&(rqp)->sr_slock)
  52. #define SMBRQ_SUNLOCK(rqp) smb_sl_unlock(&(rqp)->sr_slock)
  53. #define SMBRQ_SLOCKPTR(rqp) (&(rqp)->sr_slock)
  54. enum smbrq_state {
  55. SMBRQ_NOTSENT, /* rq have data to send */
  56. SMBRQ_SENT, /* send procedure completed */
  57. SMBRQ_REPLYRECEIVED,
  58. SMBRQ_NOTIFIED /* owner notified about completion */
  59. };
  60. struct smb_vc;
  61. struct smb_t2rq;
  62. struct smb_rq {
  63. enum smbrq_state sr_state;
  64. struct smb_vc * sr_vc;
  65. struct smb_share* sr_share;
  66. u_short sr_mid;
  67. u_int32_t sr_seqno;
  68. u_int32_t sr_rseqno;
  69. struct mbchain sr_rq;
  70. u_int8_t sr_rqflags;
  71. u_int16_t sr_rqflags2;
  72. u_char * sr_wcount;
  73. void * sr_bcount; /* Points to 2-byte buffer. */
  74. struct mdchain sr_rp;
  75. int sr_rpgen;
  76. int sr_rplast;
  77. int sr_flags; /* SMBR_* */
  78. int sr_rpsize;
  79. struct smb_cred * sr_cred;
  80. int sr_timo;
  81. int sr_rexmit;
  82. int sr_sendcnt;
  83. struct timespec sr_timesent;
  84. int sr_lerror;
  85. u_int8_t * sr_rqsig;
  86. void * sr_rqtid; /* Points to 2-byte buffer. */
  87. void * sr_rquid; /* Points to 2-byte buffer. */
  88. u_int8_t sr_errclass;
  89. u_int16_t sr_serror;
  90. u_int32_t sr_error;
  91. u_int8_t sr_rpflags;
  92. u_int16_t sr_rpflags2;
  93. u_int16_t sr_rptid;
  94. u_int16_t sr_rppid;
  95. u_int16_t sr_rpuid;
  96. u_int16_t sr_rpmid;
  97. struct smb_slock sr_slock; /* short term locks */
  98. struct smb_t2rq * sr_t2;
  99. TAILQ_ENTRY(smb_rq) sr_link;
  100. };
  101. struct smb_t2rq {
  102. u_int16_t t2_setupcount;
  103. u_int16_t * t2_setupdata;
  104. u_int16_t t2_setup[2]; /* most of rqs has setupcount of 1 */
  105. u_int8_t t2_maxscount; /* max setup words to return */
  106. u_int16_t t2_maxpcount; /* max param bytes to return */
  107. u_int16_t t2_maxdcount; /* max data bytes to return */
  108. u_int16_t t2_fid; /* for T2 request */
  109. char * t_name; /* for T request, should be zero for T2 */
  110. int t2_flags; /* SMBT2_ */
  111. struct mbchain t2_tparam; /* parameters to transmit */
  112. struct mbchain t2_tdata; /* data to transmit */
  113. struct mdchain t2_rparam; /* received parameters */
  114. struct mdchain t2_rdata; /* received data */
  115. struct smb_cred*t2_cred;
  116. struct smb_connobj *t2_source;
  117. struct smb_rq * t2_rq;
  118. struct smb_vc * t2_vc;
  119. };
  120. int smb_rq_alloc(struct smb_connobj *layer, u_char cmd,
  121. struct smb_cred *scred, struct smb_rq **rqpp);
  122. int smb_rq_init(struct smb_rq *rqp, struct smb_connobj *layer, u_char cmd,
  123. struct smb_cred *scred);
  124. void smb_rq_done(struct smb_rq *rqp);
  125. int smb_rq_getrequest(struct smb_rq *rqp, struct mbchain **mbpp);
  126. int smb_rq_getreply(struct smb_rq *rqp, struct mdchain **mbpp);
  127. void smb_rq_wstart(struct smb_rq *rqp);
  128. void smb_rq_wend(struct smb_rq *rqp);
  129. void smb_rq_bstart(struct smb_rq *rqp);
  130. void smb_rq_bend(struct smb_rq *rqp);
  131. int smb_rq_intr(struct smb_rq *rqp);
  132. int smb_rq_simple(struct smb_rq *rqp);
  133. int smb_t2_alloc(struct smb_connobj *layer, u_short setup, struct smb_cred *scred,
  134. struct smb_t2rq **rqpp);
  135. int smb_t2_init(struct smb_t2rq *rqp, struct smb_connobj *layer, u_short setup,
  136. struct smb_cred *scred);
  137. void smb_t2_done(struct smb_t2rq *t2p);
  138. int smb_t2_request(struct smb_t2rq *t2p);
  139. #endif /* !_NETSMB_SMB_RQ_H_ */