void construct_reply_common_req(struct smb_request *req, char *outbuf);
size_t req_wct_ofs(struct smb_request *req);
void chain_reply(struct smb_request *req);
+bool req_is_in_chain(struct smb_request *req);
void check_reload(time_t t);
void smbd_process(void);
uint32 dirtype, const char *name_in, bool has_wild);
void reply_unlink(struct smb_request *req);
void send_file_readbraw(connection_struct *conn,
+ struct smb_request *req,
files_struct *fsp,
SMB_OFF_T startpos,
size_t nread,
*/
#define COPYBUF_SIZE (8*1024)
-/*
- * Used in chaining code.
- */
-extern int chain_size;
-
/*
* Map the Core and Extended Oplock requesst bits down
* to common bits (EXCLUSIVE_OPLOCK & BATCH_OPLOCK).
/* Note that chain_size must be available as an extern int to this macro. */
-#define smb_offset(p,buf) (PTR_DIFF(p,buf+4) + chain_size)
+#define smb_offset(p,buf) (PTR_DIFF(p,buf+4))
#define smb_len(buf) (PVAL(buf,3)|(PVAL(buf,2)<<8)|((PVAL(buf,1)&1)<<16))
#define _smb_setlen(buf,len) do { buf[0] = 0; buf[1] = ((len)&0x10000)>>16; \
enum protocol_types Protocol = PROTOCOL_COREPLUS;
-/* this is used by the chaining code */
-int chain_size = 0;
-
static enum remote_arch_types ra_type = RA_UNKNOWN;
/***********************************************************************
/* Only do this on non-chained and non-chaining reads not using the
* write cache. */
- if (chain_size !=0 || (CVAL(req->vwv+0, 0) != 0xFF)
- || (lp_write_cache_size(SNUM(conn)) != 0) ) {
+ if (req_is_in_chain(req) || (lp_write_cache_size(SNUM(conn)) != 0)) {
return False;
}
/* Only do this on non-chained and non-chaining reads not using the
* write cache. */
- if (chain_size !=0 || (CVAL(req->vwv+0, 0) != 0xFF)
- || (lp_write_cache_size(SNUM(conn)) != 0) ) {
+ if (req_is_in_chain(req) || (lp_write_cache_size(SNUM(conn)) != 0)) {
return False;
}
Determine if this is a secondary element of a chained SMB.
**************************************************************************/
-static bool in_chained_smb(void)
-{
- return (chain_size != 0);
-}
-
static void received_unlock_msg(struct messaging_context *msg,
void *private_data,
uint32_t msg_type,
blocking_lock_record *blr;
NTSTATUS status;
- if(in_chained_smb() ) {
+ if(req_is_in_chain(req)) {
DEBUG(0,("push_blocking_lock_request: cannot queue a chained request (currently).\n"));
return False;
}
connection_struct *conn;
struct smb_request *req;
- chain_size = 0;
-
if (!(req = talloc(talloc_tos(), struct smb_request))) {
smb_panic("could not allocate smb_request");
}
exit_server_cleanly(NULL);
}
+
+bool req_is_in_chain(struct smb_request *req)
+{
+ if (req->vwv != (uint16_t *)(req->inbuf+smb_vwv)) {
+ /*
+ * We're right now handling a subsequent request, so we must
+ * be in a chain
+ */
+ return true;
+ }
+
+ if (!is_andx_req(req->cmd)) {
+ return false;
+ }
+
+ if (req->wct < 2) {
+ /*
+ * Okay, an illegal request, but definitely not chained :-)
+ */
+ return false;
+ }
+
+ return (CVAL(req->vwv+0, 0) != 0xFF);
+}
****************************************************************************/
void send_file_readbraw(connection_struct *conn,
+ struct smb_request *req,
files_struct *fsp,
SMB_OFF_T startpos,
size_t nread,
* reply_readbraw has already checked the length.
*/
- if ( (chain_size == 0) && (nread > 0) && (fsp->base_fsp == NULL) &&
+ if ( !req_is_in_chain(req) && (nread > 0) && (fsp->base_fsp == NULL) &&
(fsp->wcp == NULL) && lp_use_sendfile(SNUM(conn)) ) {
ssize_t sendfile_read = -1;
char header[4];
(unsigned long)mincount,
(unsigned long)nread ) );
- send_file_readbraw(conn, fsp, startpos, nread, mincount);
+ send_file_readbraw(conn, req, fsp, startpos, nread, mincount);
DEBUG(5,("reply_readbraw finished\n"));
END_PROFILE(SMBreadbraw);
* on a train in Germany :-). JRA.
*/
- if ((chain_size == 0) && (CVAL(req->vwv+0, 0) == 0xFF) &&
+ if (!req_is_in_chain(req) &&
!is_encrypted_packet(req->inbuf) && (fsp->base_fsp == NULL) &&
lp_use_sendfile(SNUM(conn)) && (fsp->wcp == NULL) ) {
uint8 headerbuf[smb_size + 12 * 2];